how to read date from datagrid ??

  • Thread starter Thread starter Tor Lund
  • Start date Start date
T

Tor Lund

hi, i am populating a datagrid with datatables from a dataset. how do i read
data's from the datagrid ???. i want to select a number from af table in the
datagrid... i know how to do it in asp.net but not in a windows form
development.. can anybody help me out ??

thanks
Tor Lund
 
Hi Tor,

This is not that simple but possible. The first thing to do is to retrieve
the CurrencyManager instance managing the current record for the DataGrid.
This is done like this:

CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid.DataSource,
dataGrid.DataMember];

// Now, get the current position and the reference to the data view used to
display the data.

int pos = cm.Position;
DataView theView = (DataView)cm.List;

// And finally, get the value!

string firstName = (string)theView[pos]["FirstName"];



NB: The code hasn't been tested - this is rather a sample sequence to
follow.
 
Back
Top