datagridview的行点击datagridview

2023-09-03 02:42:38 作者:有爱就有恨

我有一个充满了从数据库数据的一个DataGridView,我需要做到这一点: 当在数据网格上连续点击所有与该行数据的字段将在其他文本框或别的东西。怎么办呢?先谢谢了。

I have a datagridview which is filled with data from db and i need to do this: when click on a row in datagrid all the fields with data from this row will be in other textboxes or something else. How to do so? Thanks in advance.

推荐答案

在你的 CellClick 事件,请INT rowIndex位置= e.RowIndex 。从那里,你可以做的DataGridViewRow行= DataGridView1.Rows [rowIndex位置] 并访问所有细胞(或更好然而,从根本数据表)。

On your CellClick event, do int rowIndex = e.RowIndex. From there you can do DataGridViewRow row = DataGridView1.Rows[rowIndex] and access all the cells in row (or better yet, from your underlying DataTable).