DataGridViewBand.ContextMenuStrip プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewBand.ContextMenuStrip プロパティの意味・解説 

DataGridViewBand.ContextMenuStrip プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

バンドショートカット メニュー取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Overridable Property
 ContextMenuStrip As ContextMenuStrip
Dim instance As DataGridViewBand
Dim value As ContextMenuStrip

value = instance.ContextMenuStrip

instance.ContextMenuStrip = value
public virtual ContextMenuStrip ContextMenuStrip { get;
 set; }
public:
virtual property ContextMenuStrip^ ContextMenuStrip {
    ContextMenuStrip^ get ();
    void set (ContextMenuStrip^ value);
}
/** @property */
public ContextMenuStrip get_ContextMenuStrip ()

/** @property */
public void set_ContextMenuStrip (ContextMenuStrip
 value)
public function get ContextMenuStrip
 () : ContextMenuStrip

public function set ContextMenuStrip
 (value : ContextMenuStrip)

プロパティ
現在の DataGridViewBand に関連付けられている ContextMenuStrip。既定値null 参照 (Visual Basic では Nothing) です。

解説解説

ユーザーバンド表示領域マウス右ボタンクリックすると、ショートカット メニュー表示されます。表示領域は、DataGridView 内の DataGridViewColumn または DataGridViewRow です。

使用例使用例

DataGridViewColumn の ContextMenuStrip プロパティ使用してセル背景色変更するための機能追加するコード例次に示します。このコード例は、DataGridViewColumn クラストピック取り上げているコード例一部分です。

WithEvents toolStripItem1 As New
 ToolStripMenuItem()

Private Sub AddContextMenu()
    toolStripItem1.Text = "Redden"
    Dim strip As New ContextMenuStrip()
    For Each column As DataGridViewColumn
 _
        In dataGridView.Columns()

        column.ContextMenuStrip = strip
        column.ContextMenuStrip.Items.Add(toolStripItem1)
    Next
End Sub
' Change the cell's color.
Private Sub toolStripItem1_Click(ByVal
 sender As Object, _
    ByVal args As EventArgs) _
    Handles toolStripItem1.Click

    dataGridView.Rows(mouseLocation.RowIndex) _
        .Cells(mouseLocation.ColumnIndex) _
        .Style.BackColor = Color.Red
End Sub

Private mouseLocation As DataGridViewCellEventArgs

' Deal with hovering over a cell.
Private Sub dataGridView_CellMouseEnter(ByVal
 sender As Object, _
    ByVal location As DataGridViewCellEventArgs)
 _
    Handles DataGridView.CellMouseEnter

    mouseLocation = location
End Sub
ToolStripMenuItem toolStripItem1 = new ToolStripMenuItem();

private void AddContextMenu()
{
    toolStripItem1.Text = "Redden";
    toolStripItem1.Click += new EventHandler(toolStripItem1_Click);
    ContextMenuStrip strip = new ContextMenuStrip();
    foreach (DataGridViewColumn column in dataGridView.Columns)
    {

        column.ContextMenuStrip = strip;
        column.ContextMenuStrip.Items.Add(toolStripItem1);
    }
}

private DataGridViewCellEventArgs mouseLocation;

// Change the cell's color.
private void toolStripItem1_Click(object sender,
 EventArgs args)
{
    dataGridView.Rows[mouseLocation.RowIndex]
        .Cells[mouseLocation.ColumnIndex].Style.BackColor
        = Color.Red;
}

// Deal with hovering over a cell.
private void dataGridView_CellMouseEnter(object
 sender,
    DataGridViewCellEventArgs location)
{
    mouseLocation = location;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewBand クラス
DataGridViewBand メンバ
System.Windows.Forms 名前空間
ContextMenuStrip クラス
DataGridView クラス
DataGridView.RowContextMenuStripNeeded イベント
DataGridViewRow
DataGridViewColumn



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DataGridViewBand.ContextMenuStrip プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewBand.ContextMenuStrip プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS