如何在Datagrid中获取行单击事件?

时间:2012-11-23 06:06:59

标签: vb.net

情况如下: -

I binded an Id to a column in a datagrid.
and now i want to pass that Id to row click event of this Datagrid.

1.What is the row click event of Datagrid?

2.How to pass this Id to the event?

任何指导都将不胜感激。

由于

1 个答案:

答案 0 :(得分:0)

使用此示例,您可以捕获行索引和列索引

Private Sub DataGridView1_CellMouseClick(sender As [Object], e As DataGridViewCellMouseEventArgs)

    Dim cellInformation As New System.Text.StringBuilder()
    cellInformation.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex)
    cellInformation.AppendLine()
    cellInformation.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex)
    cellInformation.AppendLine()
    MessageBox.Show(cellInformation.ToString(), "CellMouseClick Event")
End Sub