Click here to Skip to main content
15,905,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

In my Form1 i have
Datagridview1,Contextmenustrip1.

when i click on any cell and on Rightclick, i am showing Contextmenustrip1.

My problem is i have 2 rows With 5 Columns in Datagridview1,
suppose if i select Datagridview1.Rows[0].cell[0]
and i right click on Datagridview1.Rows[1].cells[4],

means selected Cell is different and Right Clicked cell is different.

i don't want to show contextmenustrip1 if both selected and rightclicked cell's are different.

if both are same want to show contextmenustrip1.

Any idea or suggestion would be really appreciated.

Regards,
Pawan.
Posted
Updated 17-Sep-10 5:32am
v2

1 solution

the first thing you need to do is making sure that what ever you right clicked on is the selected cell; you can do this by handling "CellMouseDown" event on the gridview and select the cell in programmatic fashion like
datagridview1[e.columnindex,e.rowindex].selected=true;


and hence there won't even be a need for you to validate if the cell right clicked on and the selected one are different cells.

I hope that helped
good luck
 
Share this answer
 
Comments
Pawan Kiran 20-Sep-10 6:41am    
Dear samqty,

i solved the issue with the help of CellMouseDown event.
Thanks to U.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900