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

ShortcutKey in default contextmenu of Grid

1 Answer 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 14 Sep 2010, 12:01 PM
Hello,

I am using 2010 version of Winform.
I want to add ShortcutKey ( Hotkey) in default contextmenu of Gridview.

Like,
hiding column ----  ctrl+H
column chosser ----  ctrl+c
Export ----  ctrl+E

How can i accomplish this?
Please put some code to understand, if possible.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 Sep 2010, 05:54 PM
Hi James,

Thank you for the question.

Basically, in order to implement your scenario you should handle the ContextMenuOpening event and assgning RadSchortcuts depending on the Text of the menu items:
public Form1()
{
    InitializeComponent();
  
    this.radGridView1.ContextMenuOpening += new Telerik.WinControls.UI.ContextMenuOpeningEventHandler(radGridView1_ContextMenuOpening);
}
  
void radGridView1_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
{
    for (int i = 0; i < e.ContextMenu.Items.Count; i++)
    {
        if (e.ContextMenu.Items[i].Text == "Column Chooser")
        {
            e.ContextMenu.Items[i].Shortcuts.Add(new RadShortcut(Keys.Control, Keys.C));
        }
    }
}

I hope this helps.

Kind regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or