Link to home
Start Free TrialLog in
Avatar of SheldonC
SheldonCFlag for Saint Kitts and Nevis

asked on

How do I change focus of the row a datagridview control to the row that is right-clicked before a contextmenustrip option is selected or shown?

I have a context menu strip attached to a datagridview control. My context menu strip has two options, add a row or remove a row. I am able to do both successfully but I am having a problem remove the correct row when I right click on the row in question. It would only remove the row that was last selected or  in other words, that I last left clicked on.

I attempted to use the mouse_click event of the datagridview control but it is executed after the menu strip options have been displayed and selected.
Avatar of SheldonC
SheldonC
Flag of Saint Kitts and Nevis image

ASKER

Any ideas guys?
Avatar of Mrunal
jQuery can help you in this scenario.

check this out:

http://stackoverflow.com/questions/1206203/how-to-distinguish-between-left-and-right-mouse-click-with-jquery

Other mouse events:

http://api.jquery.com/category/events/mouse-events/

you can also prevent contextmenu poping up.
Isn't jquery a javascript command? I am using VB .Net
@mroonal
Little tip: datagridview is winforms. Gridview is webforms :-)



Either handle the CellClick event of the grid and set the currentcell or handle the Click event, supply the x,y to HitTest method to find the cell under click and set the currentcell.
can I get a code sample?
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland 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