Articles in this section
Category / Section

How to use the editing related events in TreeGridCheckBoxColumn of WinUI TreeGrid (SfTreeGrid)?

1 min read

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

//Event subscription
this.sfTreeGrid.CurrentCellValueChanged += OnCurrentCellValueChanged;
 
//Event customization
private void OnCurrentCellValueChanged(object sender, TreeGridCurrentCellValueChangedEventArgs e)
{
    int columnindex = sfTreeGrid.ResolveToGridVisibleColumnIndex(e.RowColumnIndex.ColumnIndex);
 
    if (columnindex < 0) 
        return;
 
    var column = sfTreeGrid.Columns[columnindex];
 
    if (column is TreeGridCheckBoxColumn)
    {
        var recordIndex = sfTreeGrid.ResolveToNodeIndex(e.RowColumnIndex.RowIndex);
 
        if (recordIndex < 0)
            return;
 
        TreeNode node = null;
 
        if (this.sfTreeGrid.View != null)
        {       
            //Get the TreeNode
            node = this.sfTreeGrid.View.Nodes[recordIndex];
 
            if (node != null)
            {
                //Checkbox property changed value is stored here.
                var value = (node.Item as EmployeeInfo).Availability;
            }
        }
    }
}

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

View sample in GitHub

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