Solved

Datagrid right click  -- open menu

Posted on 2004-04-19
6
815 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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