# Checkbox Selection

## Content

Checkbox selection provides an easier, visual-based method for managing multiple row selections within the FlexGrid. By setting the grid's SelectionMode property, a checkbox is automatically inserted into the first column of each row, allowing users to select or deselect rows individually or in groups without relying on keyboard or mouse shortcuts.
![fd2fc1b3-e109-4e89-ba96-820e98da0046.png](https://cdn.mescius.io/document-site-files/images/2f10b028-0ae8-4c29-a102-4d67578c339b/fd2fc1b3-e109-4e89-ba96-820e98da0046.433fea.png?width=500)

## Checkbox Selection Modes

The FlexGrid checkbox feature supports three primary modes of operation, designed to handle individual rows, hierarchical structures, and bulk selection.

1. **Individual Row Selection**

This mode is automatically engaged when the FlexGrid displays hierarchical data.
When a parent node (group row) is selected, all its child nodes are automatically selected. Conversely, changing the state of a child node updates the parent node's checkbox. This feature utilizes a tri-state logic to indicate the parent row's status:

* **Checked:** All child nodes are selected.
* **Unchecked:** No child nodes are selected.
* **Partially Checked (Tri-State):** Only a subset of the child nodes are selected.

![](https://cdn.mescius.io/document-site-files/images/2f10b028-0ae8-4c29-a102-4d67578c339b/IndividualRowSelection-ezgif.com-resize.426b1d.gif?width=500)

2. **Tree Mode Selection**

This mode is automatically engaged when the FlexGrid displays hierarchical data.
When a parent node (group row) is selected, all its child nodes are automatically selected. Conversely, changing the state of a child node updates the parent node's checkbox. This feature utilizes a tri-state logic to indicate the parent row's status:

* **Checked:** All child nodes are selected.
* **Unchecked:** No child nodes are selected.
* **Partially Checked (Tri-State):** Only a subset of the child nodes are selected.

![](https://cdn.mescius.io/document-site-files/images/2f10b028-0ae8-4c29-a102-4d67578c339b/TreeModeSelection-ezgif.com-resize.e58fbf.gif)

3. **Select All (Fixed Row) Selection**

This mode provides a single, convenient control for bulk selection.
FlexGrid automatically inserts an additional checkbox into the first cell of the fixed header row. This checkbox acts as the master select-all control. Toggling this checkbox selects or deselects all visible data rows in the grid at once.
This control also operates in a tri-state manner:

* **Checked:** All data rows are selected.
* **Unchecked:** All data rows are deselected.
* **Partially Checked (Tri-State):** Some but not all data rows are selected.

![](https://cdn.mescius.io/document-site-files/images/2f10b028-0ae8-4c29-a102-4d67578c339b/SelectAllFixedRowSelection-ezgif.com-resize.070152.gif)

## Sample Usage

The following code demonstrates the minimum required configuration to enable checkbox selection on a FlexGrid control.

```csharp
using C1.Win.FlexGrid;
public partial class MainForm : Form
{
    public MainForm()
    {
        InitializeComponent();
        flexGrid.SelectionMode = SelectionModeEnum.CheckBox;
    }
}
```


