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

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

ContextMenuStrip.SourceControl プロパティ

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

この ContextMenuStrip を表示した最後コントロール取得します

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

Dim instance As ContextMenuStrip
Dim value As Control

value = instance.SourceControl
public Control SourceControl { get; }
public:
property Control^ SourceControl {
    Control^ get ();
}
/** @property */
public Control get_SourceControl ()

プロパティ
この ContextMenuStrip表示したコントロール

解説解説
使用例使用例

どのコントロールメニュー表示されたかを SourceControl使用して動的に判断する方法と、Opening イベント処理方法次のコード例示します。このコード例は、ContextMenuStrip クラストピック取り上げているコード例一部分です。

' This event handler is invoked when the ContextMenuStrip
' control's Opening event is raised. It demonstrates
' dynamic item addition and dynamic SourceControl 
' determination with reuse.
 Sub cms_Opening(ByVal sender As
 Object, ByVal e As System.ComponentModel.CancelEventArgs)

     ' Acquire references to the owning control and item.
     Dim c As Control = fruitContextMenuStrip.SourceControl
     Dim tsi As ToolStripDropDownItem = fruitContextMenuStrip.OwnerItem
 

     ' Clear the ContextMenuStrip control's 
     ' Items collection.
     fruitContextMenuStrip.Items.Clear()

     ' Check the source control first.
     If Not (c Is Nothing)
 Then
         ' Add custom item (Form)
         fruitContextMenuStrip.Items.Add(("Source: "
 + c.GetType().ToString()))
     ElseIf Not (tsi Is
 Nothing) Then
         ' Add custom item (ToolStripDropDownButton or ToolStripMenuItem)
         fruitContextMenuStrip.Items.Add(("Source: "
 + tsi.GetType().ToString()))
     End If

     ' Populate the ContextMenuStrip control with its default items.
     fruitContextMenuStrip.Items.Add("-")
     fruitContextMenuStrip.Items.Add("Apples")
     fruitContextMenuStrip.Items.Add("Oranges")
     fruitContextMenuStrip.Items.Add("Pears")

     ' Set Cancel to false. 
     ' It is optimized to true based on empty entry.
     e.Cancel = False
 End Sub
// This event handler is invoked when the ContextMenuStrip
// control's Opening event is raised. It demonstrates
// dynamic item addition and dynamic SourceControl 
// determination with reuse.
void cms_Opening(object sender, System.ComponentModel.CancelEventArgs
 e)
{
    // Acquire references to the owning control and item.
    Control c = fruitContextMenuStrip.SourceControl as Control;
    ToolStripDropDownItem tsi = fruitContextMenuStrip.OwnerItem as ToolStripDropDownItem;

    // Clear the ContextMenuStrip control's Items collection.
    fruitContextMenuStrip.Items.Clear();

    // Check the source control first.
    if (c != null)
    {
        // Add custom item (Form)
        fruitContextMenuStrip.Items.Add("Source: " + c.GetType().ToString());
    }
    else if (tsi != null)
    {
        // Add custom item (ToolStripDropDownButton or ToolStripMenuItem)
        fruitContextMenuStrip.Items.Add("Source: " + tsi.GetType().ToString());
    }

    // Populate the ContextMenuStrip control with its default items.
    fruitContextMenuStrip.Items.Add("-");
    fruitContextMenuStrip.Items.Add("Apples");
    fruitContextMenuStrip.Items.Add("Oranges");
    fruitContextMenuStrip.Items.Add("Pears");

    // Set Cancel to false. 
    // It is optimized to true based on empty entry.
    e.Cancel = false;
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からContextMenuStrip.SourceControl プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からContextMenuStrip.SourceControl プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からContextMenuStrip.SourceControl プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS