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

Remove items from default context menu

1 Answer 417 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tommy
Top achievements
Rank 1
Tommy asked on 21 Oct 2008, 06:40 AM
Hi,

I'm using the default context menu for the RadGrid in our application. It has all teh features the customer needs but there are 2 little issues:

- The menu item "edit" still appears in the default menu even when Editing is disabled. Shouldn't that be removed automatically?

- The only item(s) I want to remove from the context menu are copy and paste. The user doesn't need to do that and it produces an error when he copies a text or  a number into a DateField. Sure I can validate that in the code but I would rather remove the two items.

Is ist possible to remove the items and keep the default menu or do I have to create a custom only because of that?

Thanks

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 21 Oct 2008, 11:40 AM
Hello Tommy,

Thank you for contacting us and your feedback. We will consider disabling the Edit option when editing is disabled. Thank you for the pointer.

You can hide the Edit, Copy, and the separator item options in the context menu using the following event:

private void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)  
        {  
            e.ContextMenu.Items[0].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;  
            e.ContextMenu.Items[1].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;  
            e.ContextMenu.Items[2].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;      
        } 

...or you can make them disabled if you replace each of the three lines above with:

e.ContextMenu.Items[i-th].Enabled = false

The Paste option should never appear if Copy is hidden/disabled.

Do not hesitate to contact me back if you need further assistance.

 
Kind regards,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Tommy
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or