Solved

DataGrid Context Menu

Posted on 2006-06-21
4
2,466 Views
Last Modified: 2008-01-09
I have a custom datagrid that is being used within an application.  My problem is that when the user right clicks a row within the datagrid,  and selects an option from the context menu, the active row is still the last active row, not the one that was right clicked on.  What I need to do is when someone right clicks on a row, select that row before the context menu pops up.  This custom datagrid is also set up for rowselect.  The problem is that if I use the mousedown event, after the mouse down event, the textbox within the datagrid's row becomes active, therefore I never get the datagrids doubleclick event.  I currently use the mouseup event for the row selecting, but the context menu comes up before the row is selected.  What are my options?????
0
Comment
Question by:gvector1
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16953696
Option:

In the DataGrid's MouseDown event handler, do a hit test, and get the row index, and set the current row to that value.

Bob
0
 

Author Comment

by:gvector1
ID: 16954274
That works on one level.  I also need to be able to double click the row and open up that specific record.  If I select the row on the mouse down event, it then sets the focus on the textbox within the specific cell.  I have been using the mouseup event to handle that approach so far.  Using mouse down sets the focus to the cell.  Any suggestions?????
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 16954441
In the MouseDown event handler, check to see if it's a right mouse click, before setting the current row.

Bob
0
 

Author Comment

by:gvector1
ID: 16954513
That is kind of what I was thinking.  So in the mousedown check if the right click was pressed and if so set the current row.  And on the mouse up, continue using my current code.  That seems to work.  Thanks for the help.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Finally almost got it 5 36
Why does my excel data start at B1 instead of A1. 9 85
Where did System.Data.Objects go? 2 28
Expression Evaluater 3 26
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…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

810 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