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

現在のセルの行インデックス。

戻り値

親の ContextMenuStripDataGridView、または DataGridViewRow に割り当てられた DataGridViewColumn がある場合は ContextMenuStrip。それ以外の場合は null

例外

セルの DataGridView プロパティが null ではなく、指定した rowIndex が 0 未満か、コントロールに含まれる行数から 1 を引いた値を上回っています。

ColumnIndex が 0 未満です。これは、セルが行ヘッダーのセルであることを示します。

注釈

セルに が関連付けられていない ContextMenuStrip場合、次の優先順位を使用して、その親からセルが継承されます。

  1. このセルの ContextMenuStrip

  2. 所有する行の DataGridViewRow.ContextMenuStrip

  3. 所有する列の DataGridViewColumn.ContextMenuStrip

  4. 親テーブルの System.Windows.Forms.ContextMenuStrip

ショートカット メニューは、Windows ネイティブ リソースMicrosoftされ、その有効期間は通常、 メソッドまたはデストラクターによってDispose指示されます。

メソッドに、 を GetInheritedContextMenuStrip 取得するために使用した行インデックスを渡します DataGridViewCell。 パラメーターには プロパティをRowIndexrowIndex使用しないでください。 行が共有されている場合、 RowIndex は -1 で、 の有効な値 rowIndexではありません。

適用対象

こちらもご覧ください