Solved

DataGrid Context Menu

Posted on 2006-06-21
4
2,464 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This video discusses moving either the default database or any database to a new volume.
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…

707 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