this.dataGrid.Loaded += OnDataGrid_Loaded;
private void OnDataGrid_Loaded(object sender, RoutedEventArgs e)
{
this.dataGrid.View.Records.CollectionChanged += OnRecords_CollectionChanged;
this.dataGrid.View.RecordPropertyChanged += OnView_RecordPropertyChanged;
}
private void OnView_RecordPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
// Do you customization here.
}
private void OnRecords_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
// Do you customization here.
}
} |
Hi Carlos,
Thanks for contacting Syncfusion support.
In SfDataGrid, the SfDataGrid.View.Records.CollectionChanged event will raise whenever any new record is added or removed from the underlying datasource and the SfDataGrid.View.RecordPropertyChanged event will raise when any existing data is changed. You can use these events to achieve your requirement as shown in the following code example.
Code example :
this.dataGrid.Loaded += OnDataGrid_Loaded;private void OnDataGrid_Loaded(object sender, RoutedEventArgs e){this.dataGrid.View.Records.CollectionChanged += OnRecords_CollectionChanged;this.dataGrid.View.RecordPropertyChanged += OnView_RecordPropertyChanged;}private void OnView_RecordPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e){// Do you customization here.}private void OnRecords_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e){if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add){// Do you customization here.}}
Please let us know if you require further assistance from us.
Regards,Mohanram A.