DataGridViewCell.GetInheritedContextMenuStrip(Int32) DataGridViewCell.GetInheritedContextMenuStrip(Int32) DataGridViewCell.GetInheritedContextMenuStrip(Int32) DataGridViewCell.GetInheritedContextMenuStrip(Int32) Method

定義

取得目前儲存格的繼承捷徑功能表。Gets the inherited shortcut menu for the current cell.

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 Int32 Int32 Int32

目前儲存格的資料列索引。The row index of the current cell.

傳回

例外狀況

儲存格的 DataGridView 屬性值不是 null,而且指定的 rowIndex 小於 0 或大於控制項中的資料列數減去 1。The value of the DataGridView property of the cell is not null and the specified rowIndex is less than 0 or greater than the number of rows in the control minus 1.

ColumnIndex 小於 0,表示儲存格是資料列行首儲存格。ColumnIndex is less than 0, indicating that the cell is a row header cell.

備註

如果資料格沒有相關聯ContextMenuStrip的,它會使用下列優先順序從其父系繼承一個:If the cell does not have an associated ContextMenuStrip, it will inherit one from its parents, using the following precedence:

  1. 這個儲存格的ContextMenuStripThis cell's ContextMenuStrip

  2. 擁有資料列的DataGridViewRow.ContextMenuStripThe owning row's DataGridViewRow.ContextMenuStrip

  3. 擁有資料行的DataGridViewColumn.ContextMenuStripThe owning column's DataGridViewColumn.ContextMenuStrip

  4. 父資料表的System.Windows.Forms.ContextMenuStripThe parent table's System.Windows.Forms.ContextMenuStrip

快捷方式功能表是 Microsoft Windows 原生資源,其存留期通常Dispose是由方法或析構函式所導向。Shortcut menus are Microsoft Windows native resources whose lifetimes are typically directed by the Dispose method or the destructor.

將您用來取得的DataGridViewCell資料列索引傳遞給方法。GetInheritedContextMenuStripPass the GetInheritedContextMenuStrip method the row index you used to retrieve the DataGridViewCell. 請勿使用RowIndex rowIndex參數的屬性。Do not use the RowIndex property for the rowIndex parameter. 如果資料列是共用的RowIndex ,則為-1,這不是的有效rowIndex值。If the row is shared, RowIndex is -1, which is not a valid value for rowIndex.

適用於

另請參閱