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

Prevent row selection when click on a CheckBox cell in a row

I implement a checkbox column in a GridGroupingControl & TablesOptions.ListBoxSelectionMode = SelectionMode.One. I want to check many records to do some business but just one row is selected at the same time. The row is just selected when I click on a cell in the column that is not the checkbox column. It means that when I click on a cell in the checkbox column, it is only the checkbox cell is checked and does not select the current row. So could anyone provide my a solution, please? Thank you!

1 Reply

AR Arulpriya Ramalingam Syncfusion Team March 20, 2017 06:44 AM UTC

Hi Customer, 

Thanks for your interest in Syncfusion products. 

We have already provided KB regarding the selection of records when clicking on CheckBox. Please make use of the below KB, 

In addition to that, If you want to select many records when clicking on CheckBox , set the ListBoxSelectionMode as SelectionMode.MultiSimple. Please make use of below code and sample for your requirement, 

Code snippet 

//To select many rows 
this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiSimple; 
 
//Invoke the events to select the rows based on the checkbox value 
this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick); 
this.gridGroupingControl1.TableControlCurrentCellKeyDown += gridGroupingControl1_TableControlCurrentCellKeyDown; 
 
//Event customization for selecting CheckBox by clicking 
void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e) 
{ 
    GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    Record currentRecord = style.TableCellIdentity.DisplayElement.GetRecord(); 
    //To select the current Row 
    currentRecord.SetSelected(style.Text == "False"); 
} 
 
//Event Customization for selecting CheckBox using SpaceBar 
void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e) 
{ 
    GridStyleInfo style= e.TableControl.CurrentCell.Renderer.CurrentStyle; 
    
    if(e.Inner.KeyCode== Keys.Space && style.CellType == GridCellTypeName.CheckBox ) 
    { 
        //Raise the checkbox click event while changing the checkbox value using the space bar 
        e.TableControl.RaiseCheckBoxClick(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex,MouseEventArgs.Empty as MouseEventArgs ); 
         
    } 
 
} 

Screenshot 
 
 


Dash Board Sample: <Install Location>\Syncfusion\EssentialStudio[Version Number]\Windows\Grid.Grouping.Windows\Samples\Grouping Grid Options\Table Options Demo 


Regards, 
Arulpriya 


Loader.
Up arrow icon