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

AllowSelection based on Col

I have a grid control with 2 cols. The first col is full of drop downs. The second col is original text boxes. I want the user to be able to select multiple rows/col header in col2. In Col1 I only want the user to be able to select one cell at a time. I know how to change the allowselection property for the whole grid but I can't seem to figure how to set that for just one col. So how can I set col2 to allow basically any selection and col1 to only click one cell at a time.

Thanks.

Phil


1 Reply

CI Christopher Issac Sunder K Syncfusion Team June 11, 2010 05:08 AM UTC

Hi Philip,

Thank you for your interest in Syncfusion products.

To customize the selection of a GridControl based on columns, you can make use of Selections.Add() method under the SelectionChanged event to handle it.


public Form1()
{
InitializeComponent();

// other codes ...

this.gridControl1.SelectionChanged += new Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventHandler(gridControl1_SelectionChanged);
}

void gridControl1_SelectionChanged(object sender, Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs e)
{
if (e.Range.Top > 0 && e.Range.Left == 0) // condition for row wise selection
{
this.gridControl1.Selections.Clear();
//code to make our custom selection
this.gridControl1.Selections.Add(GridRangeInfo.Cells(e.Range.Top, 2, e.Range.Bottom, 2));
}
if (e.Range.Left == 1) // check if the selection made in first column
{
this.gridControl1.Selections.Clear(); // clear all the selections.
}
}


Please refer the following sample which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Grid_customSelection1644672000.zip

Please let me know if you have any other concerns.

Regards,
Christopher K.

Loader.
Live Chat Icon For mobile
Up arrow icon