Add Context Menu to Dockable Window

Add Context Menu to Dockable Window

M.Zirk
Advocate Advocate
502 Views
2 Replies
Message 1 of 3

Add Context Menu to Dockable Window

M.Zirk
Advocate
Advocate

Hello,

 

is it posiible to add a context menu to a dockable window?

I use a propertygrid control as child in a dockable window.

 

Regards

 

Manfred

 

0 Likes
503 Views
2 Replies
Replies (2)
Message 2 of 3

Dev_rim
Advocate
Advocate

Hi Manfred,

Do you use User Control in dockable window?

Because if you use User control for design that dockable window, an property grid is only a component on there, you can create context menu for user control and filter insiders.

 

You can check this link to see how you can create a context menu and filter it according to objects.... 

 

I also sharing the code in that page

private void MyPopupEventHandler(System.Object sender, System.EventArgs e)
 {
    // Define the MenuItem objects to display for the TextBox.
    MenuItem menuItem1 = new MenuItem("&Copy");
    MenuItem menuItem2 = new MenuItem("&Find and Replace");
    // Define the MenuItem object to display for the PictureBox.
    MenuItem menuItem3 = new MenuItem("C&hange Picture");

    // Clear all previously added MenuItems.
    contextMenu1.MenuItems.Clear();
 
    if(contextMenu1.SourceControl == textBox1)
    {
       // Add MenuItems to display for the TextBox.
       contextMenu1.MenuItems.Add(menuItem1);
       contextMenu1.MenuItems.Add(menuItem2);
    }
    else if(contextMenu1.SourceControl == pictureBox1)
    {
       // Add the MenuItem to display for the PictureBox.
       contextMenu1.MenuItems.Add(menuItem3);
    }
 }

 

Regards

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
0 Likes
Message 3 of 3

M.Zirk
Advocate
Advocate

Hello Devrim,

 

thank you for reply and the sample.

I will try this.

 

Manfred

 

 

0 Likes