Multiple Cells Selection in Grid Control

Hi,

I have a requirement in Grid Control to select multiple cells by either holding Ctrl button and Clicking on Cells Or Click a Cell and drag to select multiple cells and then right Click on these selected cells and update some status.

Please let me know how to achieve this in Grid Control.

I need this as early as possibele.

Many Thanks..


3 Replies

JJ Jisha Joy Syncfusion Team December 22, 2008 06:48 AM UTC

Hi Ankit,

Please try the following codes and let me know if this helps.

this.gridControl1.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Any;
this.gridControl1.SelectCellsMouseButtonsMask = MouseButtons.Left;


Regards,
Jisha



AT Ankit Thakkar December 22, 2008 02:12 PM UTC

Thanks for your code. Using this, I can able to Select multiple cells which is fine. Now, the issue is after selecting the cells, on my right click on the selected cells, I require the selected cells info like rownum and ColNum of selected cells.

Pls let me know the event which I can use to achieve this. I want this event to fire when I right Click on any of selected cells and how to fetch selected cells info

Pls help me with this..

Thanks..

>Hi Ankit,

Please try the following codes and let me know if this helps.

this.gridControl1.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Any;
this.gridControl1.SelectCellsMouseButtonsMask = MouseButtons.Left;


Regards,
Jisha





JJ Jisha Joy Syncfusion Team December 23, 2008 05:27 AM UTC

Hi Ankit,


This can be achieved by handling the MouseDown event and can check for MouseButtons. You can get the selected ranges from the method GetSelectedRanges. You can use GetCellsInfo method to get the style information from ranges. Please check out the code:

this.gridControl1.MouseDown += new MouseEventHandler(gridControl1_MouseDown);
this.gridControl1.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Any;
this.gridControl1.SelectCellsMouseButtonsMask = MouseButtons.Left;

void gridControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{

GridRangeInfoList rangeList;

this.gridControl1.Selections.GetSelectedRanges(out rangeList, true);
if (rangeList.Count > 0)
{

foreach (GridRangeInfo range in rangeList)
{

GridStyleInfo[] info = gridControl1.GetCellsInfo(range);

for (int i = 0; i < info.GetLength(0); i++)
{
Console.WriteLine(info[i].Text);
}

}


}
}
}

Please let me know if this helps you out.

Regards,
Jisha



Loader.
Up arrow icon