Click here to Skip to main content
14,922,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application I used Ribbon Control and added Ribbon bottond. As Edit Menu.
Same maenu items are shown on right click context menu on data grid.

As I m go on clicking (left) on cell or row header of grid Edit menu on as well as Context menu should enable and disable some menu items.

I am confused to handles the event

I have used events of DataGrid as

DataGrid_MouseDown --- to handle only on Right Click
dgMainTemplate_CurrentCellChanged
dgMainTemplate_SelectionChanged


Please suggest me
Posted
Comments
Prerak Patel 17-Aug-11 3:19am
   
Not clear. Try to rephrase your question.
Simon Bang Terkildsen 17-Aug-11 4:00am
   
What mr. Patel said. You'll proporbly also need to state which Ribbon control library you're using as there are quite a few out there.

1 solution

There are no events dgMainTemplate_CurrentCellChanged, dgMainTemplate_SelectionChanged but there are events System.Windows.Forms.DataGrid.CurrentCellChanged and System.Windows.Forms.DataGrid.SelectionChanged. The names you've written are probably just methods used or not used as event handlers for those events. You can see what really happens to the event objects if you pay attention to the operators "+=" which adds handlers to the event's invocation lists (rarely used is also the operator "-=").

You can use both events to modify menu item status. The only simple problem is: event arguments for these events does not carry information on selection or current cell (both events use the type System.EventHandler). So, in the event handler, you can typecast sender parameter DataGrid and ask the instance about the current selection or cell using System.Windows.Forms.DataGrid.CurrentCell.

See http://msdn.microsoft.com/en-us/library/system.windows.forms.datagrid.aspx[^].

—SA
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900