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

Multiple selections remain enabled on right click

Hi Haneef ...

I want to enable multiple column deletion from context menu and with the default grid settings, its not working as when i right click on any of the column, all of the previous selections are lost. How can i prevent selections from being lost ???

Regards,
Ubaid Tariq

4 Replies

HA haneefm Syncfusion Team May 17, 2007 03:40 PM UTC

Hi Ubaid,

Please use the below property setting to prevent right click from affecting any selections. This will help you.

this.gridGroupingControl1.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;

Best regards,
Haneef


QS Qingde Shi July 19, 2007 06:06 PM UTC

Hi,

Set SelectCellsMouseButtonsMask = MouseButtons.Left will also disable move current cell by right click.

How to get excel like behavior? right click a cell within selected range, selection will not clear, but if right click a cell outside the selected range, selection clears, current cell moves to the clicked cell.

Thanks,

Q

>Hi Ubaid,

Please use the below property setting to prevent right click from affecting any selections. This will help you.

this.gridGroupingControl1.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;

Best regards,
Haneef


HA haneefm Syncfusion Team July 19, 2007 06:52 PM UTC

Hi Q,

If you set the SelectCellsMouseButtonsMask property to LeftMouseButton than the grid will cancel the Right mouse click in a cell. To capture this event you can use the gridDataBoundGrid1.MouseDown event. In the event handler you can clear the selections programmatically and move the CurrentCell to the cell on which the mouse is clicked.
Below is the code snippet.

void gridDataBoundGrid1_MouseDown(object sender, MouseEventArgs e)
{
//Getting the mouse location
int row, col;
Point p = gridDataBoundGrid1.PointToClient(Control.MousePosition);
bool validRowCol = gridDataBoundGrid1.PointToRowCol(p, out row, out col);
if (validRowCol && row > 0 && col > 0)
{
if (!gridDataBoundGrid1.Selections.Ranges.AnyRangeIntersects(GridRangeInfo.Cell(row, col))
&& e.Button == MouseButtons.Right)
{
gridDataBoundGrid1.Selections.Clear(true);
gridDataBoundGrid1.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.None);
}
}
}

Here is a sample that implments the similar functionality.
http://websamples.syncfusion.com/samples/Grid.Windows/33731/mai'>http://websamples.syncfusion.com/samples/Grid.Windows/33731/main.htm">http://websamples.syncfusion.com/samples/Grid.Windows/33731/mai n.htm

Best regards,
Haneef


QS Qingde Shi July 19, 2007 07:07 PM UTC

Thanks.

That is exactly what I want.

Q

Loader.
Live Chat Icon For mobile
Up arrow icon