DataGridViewCellMouseEventArgs.RowIndex 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取单元格的从零开始的行索引。
public:
property int RowIndex { int get(); };
public int RowIndex { get; }
member this.RowIndex : int
Public ReadOnly Property RowIndex As Integer
属性值
指定行索引的整数。
示例
下面的代码示例演示了此类型的用法。
// Override OnMouseClick in a class derived from DataGridViewCell to
// enter edit mode when the user clicks the cell.
protected override void OnMouseClick(DataGridViewCellMouseEventArgs e)
{
if (base.DataGridView != null)
{
Point point1 = base.DataGridView.CurrentCellAddress;
if (point1.X == e.ColumnIndex &&
point1.Y == e.RowIndex &&
e.Button == MouseButtons.Left &&
base.DataGridView.EditMode !=
DataGridViewEditMode.EditProgrammatically)
{
base.DataGridView.BeginEdit(true);
}
}
}
' Override OnMouseClick in a class derived from DataGridViewCell to
' enter edit mode when the user clicks the cell.
Protected Overrides Sub OnMouseClick( _
ByVal e As DataGridViewCellMouseEventArgs)
If MyBase.DataGridView IsNot Nothing Then
Dim point1 As Point = MyBase.DataGridView.CurrentCellAddress
If point1.X = e.ColumnIndex And _
point1.Y = e.RowIndex And _
e.Button = MouseButtons.Left And _
Not MyBase.DataGridView.EditMode = _
DataGridViewEditMode.EditProgrammatically Then
MyBase.DataGridView.BeginEdit(True)
End If
End If
End Sub