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

Remove the default right click menu in cell edit

1 Answer 267 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jaya
Top achievements
Rank 1
jaya asked on 18 Oct 2018, 02:19 PM
How to remove the default menu in cell edit? Attached image for your reference.
I need to add the Radcontext menu in the grid’s cell edit option.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 19 Oct 2018, 10:30 AM
Hi Jaya,

You can use the CellEditorInitialized event to access the editor and change the default context menu. Here is a complete example of this:
RadContextMenu myMenu = new RadContextMenu();
public RadForm1()
{
    InitializeComponent();
    for (int i = 0; i < 5; i++)
    {
        myMenu.Items.Add(new RadMenuItem("Item" + i));
    }
    radGridView1.DataSource = GetTable();
    radGridView1.CellEditorInitialized += RadGridView1_CellEditorInitialized;
}
 
private void RadGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
    var editor = e.ActiveEditor as RadTextBoxEditor;
    if (editor != null)
    {
        var element = editor.EditorElement as RadTextBoxEditorElement;
        element.TextBoxItem.HostedControl.ContextMenu = new ContextMenu();
        element.TextBoxItem.HostedControl.MouseDown -= TextBoxItem_MouseDown;
        element.TextBoxItem.HostedControl.MouseDown += TextBoxItem_MouseDown;
    }
}
 
private void TextBoxItem_MouseDown(object sender, MouseEventArgs e)
{
    var textbox = sender as Control;
    myMenu.Show(textbox, e.Location);
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
jaya
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or