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
Solved

DataGrid Context Menu

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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