Capture value in datagrid

  • Thread starter Thread starter Dave Petersen
  • Start date Start date
D

Dave Petersen

In my C# winforms datagrid, how do I get the value of the selected cell? In
asp.net I can use:

dataGrid1.SelectedIndex

but SelectedIndex is not available in windows forms apps. HitTestInfo will
return the cell number and row number, but I need to get the actual contents
of the cell.

Thanks,
Dave
 
The DataGrid's CurrentCell property returns the selected DataGridCell.

- Pete
 
Use the Item property (which is the indexer in C#) to retrieve the value of
any cell.
Coordinates of the currently selected cell can indeed be obtained as
suggested by AirPete.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top