Articles in this section

How to uncheck the other checkboxes in the row by clicking on any one checkbox in the same row in WinForms DataGrid?

WinForms DataGrid (SfDataGrid) does not provide the direct support to uncheck the other checkboxes in the row by clicking on any one checkbox in the same row. You can uncheck the other checkboxes in the row by clicking on any one checkbox in the same row by customization the CellCheckBoxClick event in WinForms DataGrid (SfDataGrid).

sfDataGrid1.CellCheckBoxClick += SfDataGrid1_CellCheckBoxClick;
 
private void SfDataGrid1_CellCheckBoxClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellCheckBoxClickEventArgs e)
{
            //Get the clicked data row
            var rowData = (e.Record as DataRowView).Row;
 
            //get the changed state of clicked column
            var checkState = e.NewValue;
 
            //get the clicked current column
            string currentColumnName = e.Column.MappingName;
 
            // make sure all other columns that are data Type of Boolean are not checked except for this one which we will check
            if (checkState == CheckState.Checked) 
            {
                //Get the column in datatable collection
                foreach (DataColumn dc in employeeCollection.Columns)
                {
                    if (dc.ColumnName != currentColumnName && dc.DataType == typeof(Boolean))
                    {
                        rowData[dc.ColumnName] = false;
                    }
                    else if (dc.ColumnName == currentColumnName)
                    {
                        rowData[dc.ColumnName] = true;
                    }
                }
            }
}

Shows the checkbox state changing in same row of SfDataGrid

The following screenshot shows the uncheck the other checkboxes in the row by clicking on any one checkbox in the same row,
Shows the only one checkbox checked in same row in SfDataGrid
Take a moment to peruse the WinForms DataGrid - GridCheckBoxColumn documentation, where you can find about GridCheckBoxColumn with code examples.

You can download the example from GitHub 


Conclusion

I hope you enjoyed learning about how to uncheck the other checkboxes in the row by clicking on any one checkbox in the same row in WinForms DataGrid.

You can refer to our WinForms Grid feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Grid documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied