Assume you create an ArrayList containing 10 instances of some class. Let's
say it's a Person class with public properties FirstName and LastName. You
then set a winform DataGrid's DataSource property to be the ArrayList.
A user selects the 6th row in the datagrid. I can find the values of the
cells that have been selected, but what I'd really like it to be able to get
a reference to the Person instance that's been selected in the DataGrid
without iterating through the entire collection looking for a matching
primary key or similar.
Is there a way to do this?
Thanks in advance.
Mark
Claes Bergefall - 06 Dec 2004 08:44 GMT
The CurrencyManager.Current property should return
the actual object.
You can get the CurrencyManager with the following code:
myGrid.BindingContext(myDataSource, myDataMember)
/claes
> Assume you create an ArrayList containing 10 instances of some class. Let's
> say it's a Person class with public properties FirstName and LastName. You
[quoted text clipped - 11 lines]
>
> Mark