Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView CellRight click

Status
Not open for further replies.

YvonneTsang

Programmer
Sep 28, 2001
37
CA
Is there an easy way to program the right click for a cell? I want to set up my own right click options for the right click but cant figure out how to do it.
 
Just capture the mousedown event and check which mousebutton was pressed.

private void grid1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == Buttons.Right)
{
//Do Something Here
}
}

 
If you're using 2.0 framework, have a look at the ContextMenuStrip object (it is basically a custom right-click menu). You can create your own, and then assign it to the ContextMenuStrip property of your control.

Here's some reading:


Hope this helps,

Alex

[small]----signature below----[/small]
Who are you, and why should I care?
Side A: We're a community of outdated robots who refused to upgrade and came here
*changes sides*
Side B: to live a simpler existence. Free of technology.
 
Seen the "HitTestInfo Class". It actually captures clicks on all parts of datagridview
here you go..
Datagridview
datagrid
you can combine JurkMonkey's code with that.

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top