Share via


DataGridViewRowContextMenuStripNeededEventArgs.RowIndex Özellik

Tanım

Kısayol menüsü isteyen satırın dizinini alır.

public:
 property int RowIndex { int get(); };
public int RowIndex { get; }
member this.RowIndex : int
Public ReadOnly Property RowIndex As Integer

Özellik Değeri

Kısayol menüsü isteyen satırın sıfır tabanlı dizini.

Örnekler

Aşağıdaki kod örneği, çalışanın RowContextMenuStripNeeded unvanını temel alan bir ContextMenuStrip sağlamak için olayı işler. Bu örnekte, biri yöneticiler ve diğeri diğer tüm çalışanlar için iki kısayol menüsü vardır. Bu örnek, sınıfa genel bakış bölümünde DataGridViewRowContextMenuStripNeededEventArgs bulunan daha büyük bir örneğin bir parçasıdır.

void dataGridView1_RowContextMenuStripNeeded(object sender,
    DataGridViewRowContextMenuStripNeededEventArgs e)
{
    DataGridViewRow dataGridViewRow1 = dataGridView1.Rows[e.RowIndex];

    toolStripMenuItem1.Enabled = true;

    // Show the appropriate ContextMenuStrip based on the employees title.
    if ((dataGridViewRow1.Cells["Title"].Value.ToString() ==
        "Sales Manager") ||
        (dataGridViewRow1.Cells["Title"].Value.ToString() ==
        "Vice President, Sales"))
    {
        e.ContextMenuStrip = managerMenuStrip;
    }
    else
    {
        e.ContextMenuStrip = employeeMenuStrip;
    }

    contextMenuRowIndex = e.RowIndex;
}
Public Sub dataGridView1_RowContextMenuStripNeeded( _
    ByVal sender As Object, _
    ByVal e As DataGridViewRowContextMenuStripNeededEventArgs) _
    Handles dataGridView1.RowContextMenuStripNeeded

    Dim dataGridViewRow1 As DataGridViewRow = _
    dataGridView1.Rows(e.RowIndex)

    toolStripMenuItem1.Enabled = True

    ' Show the appropriate ContextMenuStrip based on the employees title.
    If dataGridViewRow1.Cells("Title").Value.ToString() = _
        "Sales Manager" OrElse _
        dataGridViewRow1.Cells("Title").Value.ToString() = _
        "Vice President, Sales" Then

        e.ContextMenuStrip = managerMenuStrip
    Else
        e.ContextMenuStrip = employeeMenuStrip
    End If

    contextMenuRowIndex = e.RowIndex
End Sub

Açıklamalar

Satır hakkında ek bilgi almak için bu özelliği kullanın.

Şunlara uygulanır

Ayrıca bkz.