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;
}

備註

根據預設,如果您在檔或檔中的元素上以滑鼠右鍵按一下滑鼠,則會顯示元素特定的預設操作功能表。 使用此事件取消操作功能表的顯示,並顯示您自己的其中一個。

適用於

另請參閱