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.
Unfortunately, activation email could not send to your email. Please try again.

Multiple selections remain enabled on right click

Thread ID:

Created:

Updated:

Platform:

Replies:

61059 May 17,2007 06:55 AM Jul 19,2007 03:07 PM Windows Forms 4
loading
Tags: GridControl
Ubaid
Asked On May 17, 2007 06:55 AM

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

haneefm [Syncfusion]
Replied On May 17, 2007 11:40 AM

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

Qingde Shi
Replied On July 19, 2007 02:06 PM

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

haneefm [Syncfusion]
Replied On July 19, 2007 02:52 PM

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

Qingde Shi
Replied On July 19, 2007 03:07 PM

Thanks.

That is exactly what I want.

Q

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;