You need to use the Form's BindingContext property to obtain the
CurrencyManager for the data source.

If it's just a DataTable use this:

  int position = BindingContext[myTable];

If it's a table inside a DataSet you can also do this:

  int position = BindingContext[myDataSet, "TableName"];

As an alternative you can also use BindingContext[whatever].Current to
return the current row.  For a DataTable I think this will be an object of
class DataRowView.  So you can do something like this:

  object columnValue = BindingContext[myTable].Current["SomeColumn"];


--
Ian Griffiths
DevelopMentor

----- Original Message -----
From: "Jay Ayliff" <[EMAIL PROTECTED]>


In a Windows Forms VB application I have a DataGrid bound to a DataTable
that was created at runtime. When I have clicked on a row in the grid how
do I find the corresponding DataRow? I can't use the DataGrid's
CurrentRowIndex because the grid is sortable, so the grid row number won't
be the same as the underlying table row number.

There must be an easy answer to this but I just can't find it.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to