Skip to content

Commit cc281a8

Browse files
authored
Modified the content
Modified the content
1 parent 21d00d4 commit cc281a8

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
11
# How to use the editing related events in GridCheckBoxColumn of WinUI DataGrid (SfDataGrid)?
2-
This example illustrates how to use the editing related events in GridCheckBoxColumn of WinUI DataGrid (SfDataGrid).
2+
3+
The **BeginEdit** and **EndEdit** events are not triggered for [GridCheckBoxColumn](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.DataGrid.GridCheckBoxColumn.html) when check or uncheck the CheckBox control in **GridCheckBoxColumn** in [WinUI DataGrid](https://www.syncfusion.com/winui-controls/datagrid) (SfDataGrid). However, you can trigger the **GridCheckBoxColumn** when the CheckBox control is checked or unchecked by using the [CurrentCellValueChanged](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.DataGrid.SfDataGrid.html#Syncfusion_UI_Xaml_DataGrid_SfDataGrid_CurrentCellValueChanged) event.
4+
5+
6+
```C#
7+
8+
//Event subscription
9+
this.dataGrid.CurrentCellValueChanged += OnCurrentCellValueChanged;
10+
11+
//Event customization
12+
public void OnCurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs args)
13+
{
14+
int columnindex = dataGrid.ResolveToGridVisibleColumnIndex(args.RowColumnIndex.ColumnIndex);
15+
16+
if (columnindex < 0)
17+
return;
18+
19+
var column = dataGrid.Columns[columnindex];
20+
21+
if (column is GridCheckBoxColumn)
22+
{
23+
var rowIndex = this.dataGrid.ResolveToRecordIndex(args.RowColumnIndex.RowIndex);
24+
25+
if (rowIndex < 0)
26+
return;
27+
28+
RecordEntry record = null;
29+
30+
if (this.dataGrid.View != null)
31+
{
32+
if (this.dataGrid.View.TopLevelGroup != null)
33+
{
34+
//Get the record when grouping applied in SfDataGrid
35+
record = (this.dataGrid.View.TopLevelGroup.DisplayElements[rowIndex] as RecordEntry);
36+
}
37+
else
38+
{
39+
record = this.dataGrid.View.Records[rowIndex] as RecordEntry;
40+
}
41+
42+
if (record != null)
43+
{
44+
//Checkbox property changed value is stored here.
45+
var value = (record.Data as OrderInfo).Review;
46+
}
47+
}
48+
}
49+
}
50+
51+
```
52+
53+
Take a moment to peruse the [WinUI DataGrid - Column Types](https://help.syncfusion.com/winui/datagrid/column-types) documentation, to learn more about column types with code examples.

0 commit comments

Comments
 (0)