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 obj开发者_如何学Goects in the DGV? I tried (mydgv.CurrentRow.index as Tool).id, but it didn't work.
Any suggestions?
Thanks,
Dave
You can access them in the ItemDataBound event of the datagridview. You can cast the e.Item.DataItem to you class.
You're looking for the DataBoundItem
property:
var row = (Tool)mydgv.CurrentRow.DataBoundItem;
精彩评论