Solved

DataGrid Context Menu

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

14 Experts available now in Live!

Get 1:1 Help Now