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!
SIGN IN To post a reply.
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,
KB Link: https://www.syncfusion.com/kb/5698/how-to-select-the-record-row-while-clicking-on-checkbox-cell
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
UG Link: https://help.syncfusion.com/windowsforms/gridgrouping/selections#selectionmode---multisimple
Dash Board Sample: <Install Location>\Syncfusion\EssentialStudio[Version Number]\Windows\Grid.Grouping.Windows\Samples\Grouping Grid Options\Table Options Demo
Sample Link: https://www.syncfusion.com/downloads/support/forum/129442/ze/MultipleSelection1520061311
Regards,
Arulpriya
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
TT Tran Thanh Phong
- Mar 18, 2017 01:26 AM UTC
- Mar 20, 2017 06:44 AM UTC