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

context menu grid view

9 Answers 379 Views
GridView
This is a migrated thread and some comments may be shown as answers.
salini
Top achievements
Rank 1
salini asked on 19 Nov 2010, 12:50 PM
hi all
i am not getting default cellcontextmenu on grid view right click
previously i disabled it.
and now i want it to work,but its not even after setting allowCellContextMenu to true.
Actually i want to allow copy on a cell and paste  it to any of the filter property.
plz help me

9 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 24 Nov 2010, 01:00 PM
Hello salini,

I am not able to reproduce the issue following the supplied information. Could you illustrate how you disable the right click? It will be best if you can share with us the code snippets which demonstrate your approach.

I am looking forward to your reply.

Regards,
Svett
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
0
Richard Slade
Top achievements
Rank 2
answered on 24 Nov 2010, 01:25 PM
Hello,

Also, ensure that you are not handling the ContextMenuOpening event and clearing the context menu as below.

Private Sub RadGridView1_ContextMenuOpening(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening
    e.ContextMenu.Items.Clear()
End Sub

Richard
0
norma
Top achievements
Rank 1
answered on 25 Mar 2011, 12:25 AM


hi,

i have used the radGridView event "ContextmenuOpening" to set up a custom context menu..
(e.contextmenu = myowncontextmenu..)
however i wish the default context menu to appear when the row clicked is the header row or filter row
of the radGridView
any idea on how to get the default context menu back ?
:)

norma
0
Emanuel Varga
Top achievements
Rank 1
answered on 25 Mar 2011, 10:17 AM
Hello Norma,

In order to show a custom menu just if the the selected cell is a data cell you should check the context menu provider, like so:
void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    if (e.ContextMenuProvider is GridDataCellElement)
    {
        // show Custom menu
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
norma
Top achievements
Rank 1
answered on 29 Mar 2011, 08:48 PM
hi Emanuel

thank you for your reply
but.. i actually was trying to ask something else:

once i set the grid view context menu to some custom menu i have created myself
i loose the default grid view context menu, (the telerik one - with all the sorting and filtering options)

my question was - how do i get the telerik default gridview context menu back?
i want to show it (instead of my own custom menu) when the user clicks on the grid view filter row.

another problem i have is that once i set the context menu to the one i have created myself
clicking the filter symbol which appears on each cell of the filter row - also does not open the default menu as it did before.

sorry i was not clear before :)
 
norma :)
0
Richard Slade
Top achievements
Rank 2
answered on 29 Mar 2011, 10:37 PM
Hi Norma,

I'd like to clarify what it is you would like to do as there seems to be some conflicting requests.

From what I can tell, you would like to provide your own context menu under some circumstances, and the default context menu under other circumstances. Please could you clarify when, and on which row types you would like your own context menu Vs the default one, or indeed, a mixture of the two. This way I can prepare a sample that is correct for your needs.

Many thanks
Richard
0
Emanuel Varga
Top achievements
Rank 1
answered on 30 Mar 2011, 09:36 AM
Hello Norma,

You are not losing it, every time the context menu required event fires you are clearing out the old items or providing a new menu, just don't do that anymore and don't cancel the event and you will have the default menu back.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Svett
Telerik team
answered on 31 Mar 2011, 04:55 PM
Hi norma,

In addition to Emanuel's answer, you can use the following code snippet that demonstrates how you should modify the context menu without affecting the dynamic building of the header's context menu:

void radGridView1_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
{
    GridCellElement cellElement = e.ContextMenuProvider as GridCellElement;
 
    if (cellElement == null || cellElement.RowInfo is GridViewFilteringRowInfo || cellElement.RowInfo is GridViewTableHeaderRowInfo)
    {
        return;
    }
 
    RadDropDownMenu menu = new RadDropDownMenu();
    menu.Items.Add(new RadMenuItem("Hello"));
    e.ContextMenu = menu;
}

I hope this helps.

Best wishes,
Svett
the Telerik team
0
norma
Top achievements
Rank 1
answered on 04 Apr 2011, 06:39 PM
oh! great! Thank you all :)
i used the contextMenuProvider
it works amazing now :) 
Tags
GridView
Asked by
salini
Top achievements
Rank 1
Answers by
Svett
Telerik team
Richard Slade
Top achievements
Rank 2
norma
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Share this question
or