Solved

Datagrid right click  -- open menu

Posted on 2004-04-19
6
807 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
Comment Utility
0
 

Author Comment

by:camasuvi
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:camasuvi
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

17 Experts available now in Live!

Get 1:1 Help Now