Click here to Skip to main content
15,887,875 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Getting value out of DataGrid while maintaining original Type? Pin
bbranded27-Feb-09 9:07
bbranded27-Feb-09 9:07 
GeneralRe: Getting value out of DataGrid while maintaining original Type? Pin
Dan Neely27-Feb-09 10:31
Dan Neely27-Feb-09 10:31 
GeneralRe: Getting value out of DataGrid while maintaining original Type? Pin
howlettt27-Feb-09 14:01
howlettt27-Feb-09 14:01 
QuestionDIV overflow attribute in IE Mobile 6.0 Pin
dwg198627-Feb-09 7:45
dwg198627-Feb-09 7:45 
QuestionNumeric formatting question Pin
bscaer27-Feb-09 6:58
bscaer27-Feb-09 6:58 
AnswerRe: Numeric formatting question Pin
led mike27-Feb-09 7:20
led mike27-Feb-09 7:20 
GeneralRe: Numeric formatting question Pin
bscaer27-Feb-09 7:24
bscaer27-Feb-09 7:24 
GeneralRe: Numeric formatting question Pin
led mike27-Feb-09 7:37
led mike27-Feb-09 7:37 
GeneralRe: Numeric formatting question Pin
PIEBALDconsult27-Feb-09 7:59
mvePIEBALDconsult27-Feb-09 7:59 
AnswerRe: Numeric formatting question [modified] Pin
PIEBALDconsult27-Feb-09 7:30
mvePIEBALDconsult27-Feb-09 7:30 
GeneralRe: Numeric formatting question Pin
bscaer27-Feb-09 7:36
bscaer27-Feb-09 7:36 
GeneralRe: Numeric formatting question Pin
PIEBALDconsult27-Feb-09 8:29
mvePIEBALDconsult27-Feb-09 8:29 
GeneralRe: Numeric formatting question Pin
bscaer27-Feb-09 8:55
bscaer27-Feb-09 8:55 
GeneralRe: Numeric formatting question Pin
PIEBALDconsult27-Feb-09 9:06
mvePIEBALDconsult27-Feb-09 9:06 
GeneralRe: Numeric formatting question Pin
Luc Pattyn27-Feb-09 10:00
sitebuilderLuc Pattyn27-Feb-09 10:00 
GeneralRe: Numeric formatting question Pin
PIEBALDconsult27-Feb-09 10:03
mvePIEBALDconsult27-Feb-09 10:03 

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.