Click here to Skip to main content
15,907,492 members
Home / Discussions / C#
   

C#

 
AnswerRe: Looking for tips & tricks Pin
Abhijit Jana27-Feb-09 20:42
professionalAbhijit Jana27-Feb-09 20:42 
GeneralRe: Looking for tips & tricks Pin
E_Gold27-Feb-09 21:14
E_Gold27-Feb-09 21:14 
AnswerRe: Looking for tips & tricks Pin
Eddy Vluggen27-Feb-09 22:31
professionalEddy Vluggen27-Feb-09 22:31 
QuestionProblem with Generic Collection and Interface Pin
_ro_bb_o27-Feb-09 19:06
_ro_bb_o27-Feb-09 19:06 
AnswerRe: Problem with Generic Collection and Interface Pin
DaveyM6928-Feb-09 2:40
professionalDaveyM6928-Feb-09 2:40 
QuestionReading a Packet assistance Pin
Andrew Timmins27-Feb-09 18:46
Andrew Timmins27-Feb-09 18:46 
AnswerRe: Reading a Packet assistance Pin
Jimmanuel28-Feb-09 1:43
Jimmanuel28-Feb-09 1:43 
QuestionTo Create Crystal Reports With Dynamic Values Pin
aashish.saalvi27-Feb-09 18:46
aashish.saalvi27-Feb-09 18:46 
QuestionC# drag and drop from Treeview to Listview Pin
AlCsharp27-Feb-09 18:01
AlCsharp27-Feb-09 18:01 
AnswerRe: C# drag and drop from Treeview to Listview Pin
Calin Tatar28-Feb-09 1:02
Calin Tatar28-Feb-09 1:02 
QuestionAny good .net obfuscator ? Pin
Kim061827-Feb-09 15:11
Kim061827-Feb-09 15:11 
AnswerRe: Any good .net obfuscator ? Pin
Eddy Vluggen27-Feb-09 23:05
professionalEddy Vluggen27-Feb-09 23:05 
Questionthe problem of set the default page for html help maker (.chm) Pin
Seraph_summer27-Feb-09 10:43
Seraph_summer27-Feb-09 10:43 
QuestionDirectory of the App file ? Pin
Mohammad Dayyan27-Feb-09 10:01
Mohammad Dayyan27-Feb-09 10:01 
AnswerRe: Directory of the App file ? Pin
Calin Tatar27-Feb-09 10:02
Calin Tatar27-Feb-09 10:02 
GeneralRe: Directory of the App file ? Pin
Mohammad Dayyan27-Feb-09 10:05
Mohammad Dayyan27-Feb-09 10:05 
QuestionUsb control channel and buzzer Pin
thomaxz.tc27-Feb-09 8:52
thomaxz.tc27-Feb-09 8:52 
AnswerRe: Usb control channel and buzzer Pin
Curtis Schlak.27-Feb-09 11:43
Curtis Schlak.27-Feb-09 11:43 
GeneralRe: Usb control channel and buzzer Pin
thomaxz.tc28-Feb-09 4:09
thomaxz.tc28-Feb-09 4:09 
QuestionProblem In Middle Tire Pin
naim khan27-Feb-09 8:19
naim khan27-Feb-09 8:19 
AnswerRe: Problem In Middle Tire Pin
Colin Angus Mackay27-Feb-09 10:19
Colin Angus Mackay27-Feb-09 10:19 
GeneralRe: Problem In Middle Tire Pin
Sava Savanovic27-Feb-09 22:47
Sava Savanovic27-Feb-09 22:47 
AnswerRe: Problem In Middle Tire Pin
Christian Graus27-Feb-09 10:40
protectorChristian Graus27-Feb-09 10:40 
QuestionGetting value out of DataGrid while maintaining original Type? [modified] Pin
bbranded27-Feb-09 7:59
bbranded27-Feb-09 7:59 
Hello,

I'm interested in being able to pull the value of a cell in a selected row as the Type that the value was originally added to the DataGrid.

The data values are hWnds of all current process threads, which is of type System.IntPtr for the purpose of ShowWindow().


However, when I attempt to use the .Value with ShowWindow() as follows:

ShowWindow(dataGrid["hWndValue", dataGrid.CurrentRow.Index].Value, 1);


the call fails citing: cannot convert object to System.IntPtr.


I'm wondering if there is:
1) a way to convert the .ToString() value of dataGrid["hWndValue", dataGrid.CurrentRow.Index].Value to System.IntPtr?
2) a way to maintain the type of the data that was placed into the cell in the DataGrid?


Obviously, I'd rather not "be sloppy" and convert from a string to a IntPtr, but it'll work.


Any input is appreciated.


Thanks very much,

Matt Brown Big Grin | :-D


[edit]

Although the above may be useful for me or others in the future; I was able to read the values into both a dictionary and the datagrid row, maintaining the type and allowing a lookup.

//"root" namespace, therefore the ThreadHandles dictionary is valid throughput the Form class
Dictionary<string,> ThreadHandles = new Dictionary<string,>();


               try
                {
                    ThreadHandles.Add(sb.ToString(), hWnd);
                    dataGrid.Rows.Add(sb.ToString(), hWnd);
                }
                catch
                {
                    dataGrid.Rows.Add(sb.ToString(), hWnd);
                }



[SOLUTION]

Thanks howlettt for the solution!

ShowWindow((System.IntPtr)(dataGrid["hWndValue", dataGrid.CurrentRow.Index].Value), 1);

modified on Friday, February 27, 2009 3:08 PM

AnswerRe: Getting value out of DataGrid while maintaining original Type? Pin
howlettt27-Feb-09 8:59
howlettt27-Feb-09 8:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.