Solved

Datagrid right click  -- open menu

Posted on 2004-04-19
6
808 Views
Last Modified: 2010-08-05

It is easy to assign a contextmenu to a datagrid. But i wonder when a cell is active and the user clicks thr right click how can i open a specialized menu ?
0
Comment
Question by:camasuvi
6 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 10858578
0
 

Author Comment

by:camasuvi
ID: 10858995
Thanks but i saw the page.

This is something else....

do you have some code examples ? did you try ?

Thanks
0
 
LVL 5

Expert Comment

by:tgannetts
ID: 10859010
Would adding an event handler for the CurrentCellChanged event allow you to enable this?

The CurrentCellChanged event will fire when the user activates a cell, so you could set one of a number of pre-determined context menus for the datagrid in the event handler depending on which column or row has been selected.

Another option would be to generate HitTest info in an event handler for the Mouse_Down event, and set the context menu for whichever part of the datagrid was selected. This way a different context menu could be set when a user right-clicks on the background or column header as opposed to when clicking on a column.

Tom.

 
 
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:camasuvi
ID: 10859244
The problem,

When i activated the text in a datagrid cell the mouse_down event for the datagrid does not work....

Thanks,
0
 

Author Comment

by:camasuvi
ID: 10863189
When i attach a right click menu(Context menu) to my grid
control.. then when I select some text in the textbox
control in the grid and do RMC, i get the cut/copy/paste
RMC instead of thje menu i have associated the grid to..
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 500 total points
ID: 10864175
The problem is the following: once the cell is selected, it goes into edit mode. This creates a text box, that handles the edit operation. When you right click, the text box is actually the control that handles the click, that's why you don't get the menu associated with the datagrid.

Have a look at the following article and its example. You can generate some ideas of how to handle the right click in the text box, not in the data grid. Unfortunately you may need to write some more code yourself, rather than just attaching a menu.

http://www.syncfusion.com/faq/winforms/search/869.asp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now