Solved

Datagrid right click  -- open menu

Posted on 2004-04-19
6
812 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 70

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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

790 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