Solved

Datagrid right click  -- open menu

Posted on 2004-04-19
6
809 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Single Form 8 42
Signal R -send data to client: only if they are allowed to see it ? 1 49
Windows Media Player 2 26
Question! 4 36
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
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…

815 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

13 Experts available now in Live!

Get 1:1 Help Now