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