Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1310
Context menu fucntionality
posted

Please tell me how to apply the defaultcontextmenu of the ultradockmanager functionalities, through code

I need to create a custom context menu with ultradockmanager, I need to add Hide, Floating, Autohide, Close etc in the custom contextmenu.

I have created a contextmenu, but unable to achieve this built in functionality.

Looking forward for your reply

Parents
No Data
Reply
  • 53790
    Suggested Answer
    posted

    Hello Jeni,

    Maybe one possible solution could be:

    1. The fist step will be to disable default context menu through property: UseDefaultContextMenus = False

    2. The second step is to handle both events : MouseEnterElement and MouseLeaveElement and implement the code below:

    private void ultraDockManager1_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e)

            {

               if (e.Element is TabItemUIElement)

                    e.Element.Control.MouseDown +=new MouseEventHandler(this.OnControlMouseDown);

            }

    private void ultraDockManager1_MouseLeaveElement(object sender, Infragistics.Win.UIElementEventArgs e)

            {

            if (e.Element is TabItemUIElement)

                        e.Element.Control.MouseDown -=new MouseEventHandler(this.OnControlMouseDown);

            }  

    private void OnControlMouseDown(object sender, MouseEventArgs e)

            {

             if (e.Button == MouseButtons.Right)

                {

                 ContextMenu menu = new ContextMenu();

                 menu.MenuItems.Add("Test1");

                 menu.MenuItems.Add("Test2");

                 ((Control)sender).ContextMenu = menu;

                }

            }

    By this way the final result will be (see attached screenshot)

    Let me know if you have any questions.

    Regards

     

     

Children
No Data