We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Disabling grid row deslection from right click

Is there some way to prevent right clicks from deselecting grid rows like in the thread below?
<http://www.syncfusion.com/support/forums/message.aspx?MessageID=72563>

We are using v 5.102.0.51 and SelectCellsMouseButtonsMask does not seem to be available.




1 Reply

NA Nisha Arockiya A Syncfusion Team February 9, 2009 12:39 PM UTC

Hi Burkeharris,

Thanks for your intrest in Syncfusion Products.

The SelectionsChanging event is being hit before the mousedown event. If you want to control which is being hit first, then I think youwould have to derive the grid and over the virtuals OnSelectionChanging and OnMouseDown instead of using events.If you want to use events, then this SelectionChanging handler made it so that a right-click on selected cells does not unselect anything.
private void SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
if (e.Reason == GridSelectionReason.MouseDown & Control.MouseButtons == MouseButtons.Right)
{
int row = 0;
int col = 0;
Point pt = this.GridDataBoundGrid1.PointToClient(Control.MousePosition);
if (this.GridDataBoundGrid1.PointToRowCol(pt, row, col, -1))
{
GridRangeInfoList rangeList = null;
rangeList = this.GridDataBoundGrid1.Selections.GetSelectedRows(true, false);
if (rangeList.AnyRangeIntersects(GridRangeInfo.Cell(row, col)))
{
e.Cancel = true;
}
}
}
}


Let me know if this helps.

Regards,
Nisha.


Loader.
Live Chat Icon For mobile
Up arrow icon