Skip to content

This example illustrates how to use the editing related events in GridCheckBoxColumn of WinUI DataGrid (SfDataGrid).

Notifications You must be signed in to change notification settings

SyncfusionExamples/How-to-use-the-editing-related-events-in-checkbox-column-of-WinUI-DataGrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

How to use the editing related events in GridCheckBoxColumn of WinUI DataGrid (SfDataGrid)?

The BeginEdit and EndEdit events are not triggered when you check or uncheck the CheckBox control in GridCheckBoxColumn in WinUI DataGrid (SfDataGrid). However, you can get the notification while changing the CheckBox state by using the CurrentCellValueChanged event.

//Event subscription
this.dataGrid.CurrentCellValueChanged += OnCurrentCellValueChanged;

//Event customization
public void OnCurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs args)
{
    int columnindex = dataGrid.ResolveToGridVisibleColumnIndex(args.RowColumnIndex.ColumnIndex);

    if (columnindex < 0)
        return;

    var column = dataGrid.Columns[columnindex];

    if (column is GridCheckBoxColumn)
    {
        var rowIndex = this.dataGrid.ResolveToRecordIndex(args.RowColumnIndex.RowIndex);

        if (rowIndex < 0)
            return;

        RecordEntry record = null;

        if (this.dataGrid.View != null)
        {
            if (this.dataGrid.View.TopLevelGroup != null)
            {
                //Get the record when grouping applied in SfDataGrid
                record = (this.dataGrid.View.TopLevelGroup.DisplayElements[rowIndex] as RecordEntry);
            }
            else
            {
                record = this.dataGrid.View.Records[rowIndex] as RecordEntry;
            }

            if (record != null)
            {
                //Checkbox property changed value is stored here.
                var value = (record.Data as OrderInfo).Review;
            }
        }
    }
}

Take a moment to peruse the WinUI DataGrid - Column Types documentation, to learn more about column types with code examples.

About

This example illustrates how to use the editing related events in GridCheckBoxColumn of WinUI DataGrid (SfDataGrid).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages