Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Selected item from DataGrid

Status
Not open for further replies.
Mar 9, 2006
93
CA
I have a datagrid bound to a datasource called 'dt'. When the user Double clicks on the datagrid I want to return to them the value in the first column of the row they double clicked on. I have the double click event and can return the row number that the user clicked but cannot retrieve the data that is in the row.
Thanks
Matt
 
You can get the DataRow using the following code:
Code:
DataRow dr = ((DataRowView)((CurrencyManager)dg.BindingContext[dg.DataSource, dg.DataMember]).List[rowNum]).Row;
This assumes that the DataGrid is called dg and rowNum contains the row number you want the data from.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top