DataGridViewCell.RowIndex Właściwość

Definicja

Pobiera indeks wiersza nadrzędnego komórki.

public:
 property int RowIndex { int get(); };
[System.ComponentModel.Browsable(false)]
public int RowIndex { get; }
[<System.ComponentModel.Browsable(false)>]
member this.RowIndex : int
Public ReadOnly Property RowIndex As Integer

Wartość właściwości

Indeks wiersza zawierającego komórkę; -1, jeśli nie ma wiersza własnego.

Atrybuty

Przykłady

Poniższy przykład kodu ilustruje użycie tej właściwości.

private void getCurrentCellButton_Click(object sender, System.EventArgs e)
{
    string msg = String.Format("Row: {0}, Column: {1}",
        dataGridView1.CurrentCell.RowIndex,
        dataGridView1.CurrentCell.ColumnIndex);
    MessageBox.Show(msg, "Current Cell");
}
Private Sub getCurrentCellButton_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles getCurrentCellButton.Click

    Dim msg As String = String.Format("Row: {0}, Column: {1}", _
        dataGridView1.CurrentCell.RowIndex, _
        dataGridView1.CurrentCell.ColumnIndex)
    MessageBox.Show(msg, "Current Cell")

End Sub

Uwagi

RowIndex Gdy właściwość zwraca wartość -1, komórka jest nagłówkiem kolumny lub wiersz komórki jest współużytkowany.

Aby uzyskać więcej informacji na temat udostępniania wierszy, zobacz Najlepsze rozwiązania dotyczące skalowania kontrolki Windows Forms DataGridView.

Dotyczy

Zobacz też