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

Disable Right Click...

1 Answer 240 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Johnny
Top achievements
Rank 2
Johnny asked on 09 May 2011, 05:07 AM
How to disable the right click function where...
you mouse over your mouse to the pageview(DocumentWindow) Tab... right click.
you will see the close, close all...

May i know how to disable this function of right click?

Regards
Johnny

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 May 2011, 04:59 PM
Hi Johnny,

Thank you for writing.

RadPageView does not have a context menu on its page items by default. I guess that you are talking about the tabs of the DocumentWindows of RadDock. If this is your case, you can remove the context menu from them by setting the AllowDocumentContextMenu property of the ContextMenuService to false:
ContextMenuService menuService = this.radDock1.GetService<ContextMenuService>();
menuService.AllowDocumentContextMenu = false;
 
For more information about the ContextMenuService, please refer to this help article.

I hope the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.

Greetings,
Stefan
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Nhan
Top achievements
Rank 1
commented on 30 Jan 2024, 02:46 PM

Hi Stefan,

So, I want to custom text of context menu then how to do it? For example: Close --> Close me or Close All --> Close All Tabs

Thank you so much

Dinko | Tech Support Engineer
Telerik team
commented on 02 Feb 2024, 11:00 AM

Hi Nhan,

You can use a similar approach as demonstrated in the article mentioned in Stefan's reply. In a few words, you can get the RadMenuItemBase object in the ContextMenuDisplaying and modify the text property.

ContextMenuService menuService = this.radDock1.GetService<ContextMenuService>();
menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying;

private void menuService_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e)
{
    //the menu request is associated with a valid DockWindow instance, which resides within a DocumentTabStrip
    if (e.MenuType == ContextMenuType.DockWindow &&
        e.DockWindow.DockTabStrip is DocumentTabStrip)
    {
        //remove the "Close" menu items
        for (int i = 0; i < e.MenuItems.Count; i++)
        {
            RadMenuItemBase menuItem = e.MenuItems[i];
            if (menuItem.Name == "CloseWindow")
            {
                menuItem.Text = "Close me";
            }
            if (menuItem.Name == "CloseAll")
            {
                menuItem.Text = "Close All Tabs";
            }
        }
    }
}

Here is the result:

I hope that this approach will work for you.

Tags
PageView
Asked by
Johnny
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Share this question
or