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

How to override default context menu?

3 Answers 421 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Satyaprakash
Top achievements
Rank 1
Satyaprakash asked on 23 Jun 2008, 03:07 PM
Hi,

I want to add a context menu when i click on the column header of the Windows form RadGridView control. I also want to add another context menu when i click on a row in the RadGridView.

How could i identify that Colum header is clicked or a row in the RadGridView  is clicked?

3 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 24 Jun 2008, 07:44 AM
Hi Satyaprakash,

Thank you for writing.

You can easily do that by handling the ContextMenuOpening event of RadGridView as shown below:
void radGridView1_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e) 
  { 
   if (e.ContextMenuProvider is GridHeaderCellElement) 
   { 
    e.ContextMenu = this.columnHeaderMenu; 
   } 
   else if (e.ContextMenuProvider is GridDataCellElement) 
   { 
    e.ContextMenu = this.rowMenu; 
   } 
  } 

I hope this helps. If you have any further questions, please contact me.

Best wishes,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Gita
Top achievements
Rank 1
answered on 10 Oct 2011, 11:04 PM
<telerik:RadGridView.ContextMenu>
    <ContextMenu IsVisibleChanged="ContextMenu_IsVisibleChanged">
        <MenuItem Header="Export To Excel" Command="Commands:GlobalCommands.ExportGridToExcel" 
                  CommandParameter="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"/>
        <MenuItem Header="Export To Word" Command="Commands:GlobalCommands.ExportGridToWord"
                  CommandParameter="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"/>
    </ContextMenu>
</telerik:RadGridView.ContextMenu>
Hello Team,
We are upgrading the telerik controls to q2 2011 version. In the previous version the Radgridview right click contextmenu was working fine, but not now. What do I have to change in the above code to get the popup menu when I right click the selected row?
Let me know.

Thanks
 
0
Nikolay
Telerik team
answered on 11 Oct 2011, 07:50 AM
Hi Gita,

Your question seems to be related to our SL/WPF suites. Please note that this forum thread is in the WinForms section. I would kindly ask you to open a new thread in the appropriate forum section. This will allow the appropriate guys to handle your question and also will allow our community to find the answer more easily in case someone else has the same issue.

Thank you for your understanding.

Kind regards,

Nikolay
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Tags
GridView
Asked by
Satyaprakash
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Gita
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or