|
exhaulted wrote:
I think we've still got our wires crossed, a little background might help.
I didn't know they were crossed to begin with. You asked for help and we gave it to you. The suggestions are sound if implemented correctly. What and why you need to do isn't really relevent. As I mentioned about hard-coding passwords, if it's for anything serious it's a bad idea. That implies that if it's not important, then hard-coding it may be fine. It was only a suggestion.
Again, though, what I mentioned before for implementation does work. Shutting down the machine posts WM_QUERYENDSESSION to the application before sending WM_CLOSE or WM_QUIT (it actually doesn't even send WM_CLOSE , IIRC). It wouldn't even make sense to do it any other way. I mean, why give applications a chance to cancel the shutdown if you close the main window (which in most applications terminates the main message pump) first?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
FYI:
.NET Framework 2.0 supplies a "FormClosing" event, which sends a "CloseReason" enum which seems to contain exactly what you need.
Alas, it's a beta
there are no facts, only interpretations
|
|
|
|
|
That does indeed sound like exactly what i need, guess i'll have to try Salil's OnEndSession idea.
Kev
|
|
|
|
|
You could look for the OnSessionEnd Message by over riding WinProc. Then programticly cause the application to close.
Hope this helps....
Forever Developing
|
|
|
|
|
Thanks for that, seems like a possible solution but....
I've been looking at an example for overriding the WinProc and it seems
easy enough. The message ID is stored in the .Msg property.
Is there somewhere that lists all of the different windows messages and their equivelant .Msg values?
Cheers
Kev
|
|
|
|
|
|
I think you should forget what I told you and follow the advice posted by Heath Stewart. His solution is a "More Managed Solution"
Anyway...
Forever Developing
|
|
|
|
|
hi,
I am executing a select() method agnest a data table. I got result as DataRow[]. Here i got collection of datarow.
My question is how can i create a table from this DataRow[] without executing all unwanted iteration(iterating through individual datarow or something).
Specifically : How can i create a table from a DataRow collection.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi
If the result is the type of 'DataRowsCollection' then you can directly assign it to DataTable's Rows property.
If it is a collection of DataRows then you have to iterate one by one
M.Sendilkumar
TVS Infotech Ltd
Chennai
|
|
|
|
|
hi,
I think you didn't understood my question. See i don't want to iterate through any row hell. Do you have any other solution for this ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi Sreejith
There is no other way.But we can minimize the work in iteration.
SqlConnection con=new SqlConnection(@"Data Source=YOURSERVER\INSTANCENAME;Initial Catalog=Northwind;UID=sa; PWD=sa;");
con.Open();
SqlDataAdapter adpt=new SqlDataAdapter("select OrderID,CustomerID,EmployeeID from orders",con);
DataTable dt1=new DataTable();
adpt.Fill(dt1);
DataRow[] dr=dt1.Select("customerid='vinet'");
DataTable dt2=new DataTable();
for(int i=0;i<dr.GetLength(0);i++)
{
dt2.ImportRow(dr[i]);
}
int a=dt2.Rows.Count;
------------------------------------
try this.
---------------------------
M.Sendilkumar
TVS Infotech Ltd
Chennai
|
|
|
|
|
Right now I am working with DataGrid.CurrentRowIndex
how to do if I have to select multiple rows.
Thank you,
======
Yo need a brain to code.
|
|
|
|
|
hi,
What is your real requirement ?. We can select more than one record in a datagrid. Select() method is used to select a perticular row. And Unselect() method doing the reverse of Select(). you can check whether a perticular row is selected or not by using IsSelected() method. I recommand you to read the DataGrid Class description in MSDN.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hello Sreejit,
I have used DataGrid_MouseUp() event and then used DataGrid.CurrentRowIndex to get the current row.
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
int i = DataGrid.CurrentRowIndex;<br />
}
But how can I get multiple rows index if I have selected multiple rows.
like this>>
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
for (int i = 0; i <= DataGrid.CurrentRowIndexes:confused:; i++)<br />
{<br />
int j = DataGrid.CurrentRowIndexes[i];<br />
}<br />
}
======
Yo need a brain to code.
|
|
|
|
|
//For collecting the index of selected records
ArrayList Ar=new ArrayList();
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
for (int i = 0; i <= DataGrid.CurrentRowIndexes; i++)
{
/*this line will help you to deside whether row is selected or not. If yes then it will return a bool value. Else will return a false value.*/
if(DataGrid.IsSelected(i)
Ar.Add(DataGrid.CurrentRowIndexes[i].ToString());
else
continue;
}
}
So finally you will get all index of selected row in your ArrayList.
Remaing is upto you to design based on your requirement.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Sreeji, Thank you very much. I appreciate your help.
======
code proj. rocks!
|
|
|
|
|
Hi, I wonder if it is possible to detect somehow (from C# app) when the Windows plays some specific .wav file?
What I wanna do is to "subscribe" for that event and do my job when some specific .wav file gets played.
Any ideas?
thanks!
|
|
|
|
|
You're most likely going to be able to do this simply by a mechanism that watches if a file is read, as opposed to played specifically.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
How to I paste text to and from clipboard while preserving the formating. Because when I paste from the clipboar, the text that use to be bol is not, etc...
Say from 1 textbox into another. Or from a textbox into a word document.
Thanks
|
|
|
|
|
|
I got it to copy, my question is that why it still looses format.
Storing Info:
IDataObject d = Clipboard.GetDataObject();
//d.SetData(DataFormats.Rtf, true, richTextBox1.Text);
// d.SetData(DataFormats.Rtf, richTextBox1.Rtf);
Clipboard.SetText(richTextBox1.Text, TextDataFormat.Rtf);
Retriving info:
foreach (Word.Shape bkMark in aDoc.Shapes)
{
if (bkMark.TextFrame.TextRange.Text.Contains("heading"))
{
// bkMark.TextFrame.TextRange.Paste();
bkMark.TextFrame.TextRange.Text = Clipboard.GetText(TextDataFormat.Rtf).ToString();
//Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
//
//
}
}
|
|
|
|
|
bkMark.TextFrame.TextRange.Text contains plain text by definition, if you want formatted text you'll have to use clipboard pasting.
To have control over what will actually get pasted you'll have to specify that you want RTF. IIRC there's a PasteSpecial (or something similar) where you can tell Word what format to paste.
Regards,
mav
|
|
|
|
|
Hi
I try to use GetPrivateProfileResString to quickly retrive .ini file information but I dont know how to make a declaration....
Does someone know?
busio
|
|
|
|
|
read this article.
http://www.codeproject.com/csharp/cs_ini.asp
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|