Skip to content

DevExpress-Examples/winforms-grid-change-checkbox-state-single-click-in-multi-select-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Data Grid - Change the state of a checkbox with a single click (multi-select mode)

This example shows how to handle the MouseDown event in Grid View so that users can change the state of a checkbox with a single click. In this example, the OptionsSelection.MultiSelectMode property is set to GridMultiSelectMode.CellSelect.

private void gridView1_MouseDown(object sender, MouseEventArgs e) {
    GridHitInfo hitInfo = gridView1.CalcHitInfo(e.Location);
    if (hitInfo.InRowCell) {
        if (hitInfo.Column.RealColumnEdit is RepositoryItemCheckEdit) {
            gridView1.FocusedColumn = hitInfo.Column;
            gridView1.FocusedRowHandle = hitInfo.RowHandle;
            gridView1.ShowEditor();
            CheckEdit edit = gridView1.ActiveEditor as CheckEdit;
            if (edit == null) return;
            edit.Toggle();
            DXMouseEventArgs.GetMouseArgs(e).Handled = true;
        }
    }
}

Files to Review

Documentation