DataGridViewCell.GetInheritedContextMenuStrip(Int32) 方法

定義

取得目前儲存格的繼承捷徑功能表。

public:
 virtual System::Windows::Forms::ContextMenuStrip ^ GetInheritedContextMenuStrip(int rowIndex);
public virtual System.Windows.Forms.ContextMenuStrip GetInheritedContextMenuStrip (int rowIndex);
public virtual System.Windows.Forms.ContextMenuStrip? GetInheritedContextMenuStrip (int rowIndex);
abstract member GetInheritedContextMenuStrip : int -> System.Windows.Forms.ContextMenuStrip
override this.GetInheritedContextMenuStrip : int -> System.Windows.Forms.ContextMenuStrip
Public Overridable Function GetInheritedContextMenuStrip (rowIndex As Integer) As ContextMenuStrip

參數

rowIndex
Int32

目前儲存格的資料列索引。

傳回

如果父 ContextMenuStripDataGridViewDataGridViewRow 已指定 DataGridViewColumn,則為 ContextMenuStrip,否則為 null

例外狀況

儲存格的 DataGridView 屬性值不是 null,而且指定的 rowIndex 小於 0 或大於控制項中的資料列數減去 1。

ColumnIndex 小於 0,表示儲存格是資料列行首儲存格。

備註

如果儲存格沒有相關聯的 ContextMenuStrip ,它會使用下列優先順序,從其父代繼承其中一個:

  1. 此儲存格的 ContextMenuStrip

  2. 擁有資料列的 DataGridViewRow.ContextMenuStrip

  3. 擁有資料行的 DataGridViewColumn.ContextMenuStrip

  4. 父資料表的 System.Windows.Forms.ContextMenuStrip

快顯功能表Microsoft Windows 原生資源,其存留期通常是由 Dispose 方法或解構函式導向。

GetInheritedContextMenuStrip傳遞您用來擷取 的資料 DataGridViewCell 列索引方法。 請勿將 RowIndex 屬性用於 rowIndex 參數。 如果共用資料列, RowIndex 則為 -1,這不是 的有效值 rowIndex

適用於

另請參閱