如何从CellClick事件的数据表中的选定行中获取值

时间:2018-11-04 22:35:27

标签: vb.net datagridview datatable

我只想问一下如何从DataTable

的一行中获取值

例如:

DataTable:

col1 | col2 | col3 | col4
-------------------------
c1r1 | c2r1 | c3r1 | c4r1

c1r2 | c2r2 | c3r2 | c4r2

DataGridView中,col2被隐藏以用于显示。 col2保留显示中不包含的ID值。
因此,如果单击c4r1中的DataGridView,我可以得到col2的值c2r1并放在Label中。

我正在搜索方法,但无法获得想要的结果。

1 个答案:

答案 0 :(得分:0)

订阅DataGridView.RowEnter事件。
在那里,用当前行Label.Text单元格的Value的{​​{1}}属性:

Column(1)
相关问题