开发者

Accessing a object in a datagridview

开发者 https://www.devze.com 2023-02-11 11:37 出处:网络
I followed the simple tutorial here: http://www.codeproject.com/KB/grid/dataGridview-DataReader.aspx to create a datagridview filled with objects.

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消