This is a migrated thread and some comments may be shown as answers.

Prevent Right Mouse double click

2 Answers 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kim
Top achievements
Rank 1
Kim asked on 06 Mar 2014, 12:40 AM
Double clicking the right mouse button on a grid is firing the Grid.CellDoubleClick event, but the event does not expose which mouse button caused the event to fire.

Is there a way to prevent the CellDoubleClick even from firing when the right mouse is double clicked?

Kim

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Mar 2014, 12:17 PM
Hi Kim,

Thank you for writing.

You can make a combination with the MouseUp event of the control, where you can store the last mouse up button:
void radGridView1_MouseUp(object sender, MouseEventArgs e)
{
    _lastButtonUp = e.Button;
}
 
MouseButtons _lastButtonUp = MouseButtons.None;
 
void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
{
    switch (_lastButtonUp)
    {
        case System.Windows.Forms.MouseButtons.Left:
            MessageBox.Show("left double click");
            break;
        case System.Windows.Forms.MouseButtons.Right:
            MessageBox.Show("right double click");
            break;
        case System.Windows.Forms.MouseButtons.Middle:
            MessageBox.Show("middle double click");
            break;
    }
}

I hope this helps.

Regards,
Stefan
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

0
Kim
Top achievements
Rank 1
answered on 06 Mar 2014, 06:05 PM
Perfect, thanks!
Tags
GridView
Asked by
Kim
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Kim
Top achievements
Rank 1
Share this question
or