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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

129442 Mar 18,2017 01:26 AM UTC Mar 20,2017 06:44 AM UTC WinForms 1
loading
Tags: GridGroupingControl
Tran Thanh Phong
Asked On March 18, 2017 01:26 AM UTC

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!

Arulpriya Ramalingam [Syncfusion]
Replied On 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 


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.

Warning Icon 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.Close Icon

;