This is a migrated thread and some comments may be shown as answers.

Replace DropDown tabs with the system context menu

1 Answer 57 Views
TabbedForm
This is a migrated thread and some comments may be shown as answers.
Serg
Top achievements
Rank 1
Veteran
Serg asked on 12 Jan 2021, 04:40 AM
How to replace DropDown (New tab, Close tab, Close other ...) with the system context menu ( new ContextMenu();).
I got to delete the menu like this:
RadTabbedFormControl.ContextMenuOpening += (obj, arg) => {
                arg.ContextMenu.Items.Clear();
};

And to make a new menu, I tried to do it using MouseDown:
e.Tab.Item.MouseDown += (obj, args) => {
            if(args.Button == MouseButtons.Right)
                {
                    ContextMenu testMenu= new ContextMenu();
                    testMenu.MenuItems.Add("Test");
                    testMenu.Show(e.Tab, new Point(args.Location.X + 5, args.Location.Y - 35));
                }
};

But there was a problem with the error (Unable to display ContextMenu in invisible control) when clicking on an inactive tab.

Can you tell me another way?

1 Answer, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 13 Jan 2021, 12:02 PM

Hello, Serg,

It is possible to modify the items in the context menu by handling the RadTabbedFormControl.ContextMenuOpening event. You can clear the existing items and add new ones as demonstrated below:

private void RadTabbedFormControl1_ContextMenuOpening(object sender, RadTabbedFormControlItemConextMenuOpeningEventArgs e)
{
    //clear items
    e.ContextMenu.Items.Clear();

    //add new item
    RadMenuItem testItem = new RadMenuItem();
    testItem.Text = "test menu item";
    e.ContextMenu.Items.Add(testItem);
}

According to your last question, I suppose that you have disabled a tab so it becomes inactive and then the context menu doesn't show. Note, the point of making a tap inactive/disabled is that nothing will work on it at all. Thus, it is expected that the context menu wouldn't show. 

I hope this information helps. If you need further assistance please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TabbedForm
Asked by
Serg
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or