HtmlDocument.ContextMenuShowing イベント

定義

ユーザーがドキュメントのコンテキスト メニューの表示を要求したときに発生します。

public:
 event System::Windows::Forms::HtmlElementEventHandler ^ ContextMenuShowing;
public event System.Windows.Forms.HtmlElementEventHandler ContextMenuShowing;
public event System.Windows.Forms.HtmlElementEventHandler? ContextMenuShowing;
member this.ContextMenuShowing : System.Windows.Forms.HtmlElementEventHandler 
Public Custom Event ContextMenuShowing As HtmlElementEventHandler 

イベントの種類

次のコード例では、 イベントを ContextMenuShowing キャプチャし、それを使用して を表示します ContextMenuStrip

ContextMenuStrip menuStrip = null;

public void DetectContextMenu()
{
    if (webBrowser1.Document != null)
    {
        webBrowser1.Document.ContextMenuShowing += new HtmlElementEventHandler(Document_ContextMenuShowing);
        menuStrip = new ContextMenuStrip();
        menuStrip.Items.Add("&Custom menu item...");
    }
}

void Document_ContextMenuShowing(object sender, HtmlElementEventArgs e)
{
    menuStrip.Show(e.MousePosition);
    e.ReturnValue = false;
}

注釈

既定では、ドキュメントまたはドキュメント内の要素でマウスを右クリックすると、要素に固有の既定のコンテキスト メニューが表示されます。 このイベントを使用して、コンテキスト メニューの表示を取り消し、独自のものを表示します。

適用対象

こちらもご覧ください