Link to home
Start Free TrialLog in
Avatar of gvector1
gvector1

asked on

DataGrid Context Menu

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?????
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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
Avatar of gvector1
gvector1

ASKER

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?????
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.