/winforms-grid-multi-cell-editing

Simultaneous editing of several grid cells.

Primary LanguageC#OtherNOASSERTION

WinForms Data Grid - Simultaneous editing of several cell values

This example shows how to edit the values ​​in selected cells at the same time.

Edit Values in Selected Cells - WinForms Data Grid

bool lockEvents;
private void OnCellValueChanged(CellValueChangedEventArgs e)
{
    if (lockEvents)
        return;
    lockEvents = true;
    SetSelectedCellsValues(e.Value);
    lockEvents = false;
}
private void SetSelectedCellsValues(object value)
{
    try {
        view.BeginUpdate();
        GridCell[] cells = view.GetSelectedCells();
        ChangeMode mode = (ChangeMode)radioGroup.EditValue;
        foreach(GridCell cell in cells) {
            int rowHandle = cell.RowHandle;
            GridColumn column = cell.Column;
            switch(mode) {
                case ChangeMode.All:
                    break;
                case ChangeMode.Column:
                    column = view.FocusedColumn;
                    break;
                case ChangeMode.Row:
                    rowHandle = view.FocusedRowHandle;
                    break;
            }
            view.SetRowCellValue(rowHandle, column, value);
        }
    }
    catch(Exception ex) { }
    finally { view.EndUpdate(); }
}

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)