Reputation: 12755
I followed the simple tutorial here: http://www.codeproject.com/KB/grid/dataGridview-DataReader.aspx to create a datagridview filled with objects.
How do I access the objects in the DGV? I tried (mydgv.CurrentRow.index as Tool).id, but it didn't work.
Any suggestions?
Thanks,
Dave
Upvotes: 2
Views: 119
Reputation: 887275
You're looking for the DataBoundItem
property:
var row = (Tool)mydgv.CurrentRow.DataBoundItem;
Upvotes: 0
Reputation: 2212
You can access them in the ItemDataBound event of the datagridview. You can cast the e.Item.DataItem to you class.
Upvotes: 2