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.

AllowSelection based on Col

Thread ID:

Created:

Updated:

Platform:

Replies:

94893 Jun 8,2010 04:31 PM Jun 11,2010 01:08 AM Windows Forms 1
loading
Tags: GridControl
Philip Bishop
Asked On June 8, 2010 04:31 PM

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


Christopher Issac Sunder K [Syncfusion]
Replied On June 11, 2010 01:08 AM

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.

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.

;