Determing current table row from DataGrid

G

Guest

Hello,

i have a table. a dataView and a DataGrid.
I'm using the dataView to filter the table.
When the user double clicks on the DataGrid i want to get the data of the
first col from the row selected.
The problem is that i can't get the row number of the original table because
the grid is refering to the dataView...
what can i do?
please help...
 
R

Rob Windsor [MVP]

You can use the data binding features to get the current row instead of
finding the row number and going back to the DataSet.

\\\
BindingManagerBase bm;
DataRowView drv;
bm = dataGrid1.BindingContext[dataGrid1.DataSource,dataGrid1.DataMember];
drv = bm.Current as DataRowView;
if (drv != null)
{
MessageBox.Show(drv.Row[0].ToString());
}
///
 

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

Top