How to update WinForms GridGroupingControl when value change in DataSource?
Update the grid
By default, the cell values in the grid will be updated when the values in the underlying datasource is changed. In case, the grid is bound to the object collection or Entity framework, the property changes have to be notified to grid. This can be achieved by implementing the INotifyPropertyChanged interface to the class.
C#
/// <summary>
/// Summary description for Data with INotifyPropertyChanged interface
/// </summary>
public class Data : INotifyPropertyChanged
{
public Data()
{
}
public Data(double cat_Id, string cat_Name, string desc, string sample_Data)
{
this.cat_Id = cat_Id;
this.cat_Name = cat_Name;
this.desc = desc;
this.sample_Data = sample_Data;
}
private double cat_Id;
public double CategoryID
{
get
{
return this.cat_Id;
}
set
{
this.cat_Id = value;
OnPropertyChanged("CategoryID");
}
}
//INotifyPropertyChanged member
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Raise the event when property value changed.
/// </summary>
/// <param name="Name">Property name</param>
public void OnPropertyChanged(String Name)
{
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(Name));
}
}
}
''' <summary>
''' Summary description for Data with INotifyPropertyChanged interface
''' </summary>
Public Class Data
Implements INotifyPropertyChanged
Public Sub New()
End Sub
Public Sub New(ByVal cat_Id As Double, ByVal cat_Name As String, ByVal desc As String, ByVal sample_Data As String)
Me.cat_Id = cat_Id
Me.cat_Name = cat_Name
Me.desc = desc
Me.sample_Data = sample_Data
End Sub
Private cat_Id As Double
Public Property CategoryID() As Double
Get
Return Me.cat_Id
End Get
Set(ByVal value As Double)
Me.cat_Id = value
OnPropertyChanged("CategoryID")
End Set
End Property
'INotifyPropertyChanged member
Public Event PropertyChanged As PropertyChangedEventHandler
''' <summary>
''' Raise the event when property value changed.
''' </summary>
''' <param name="Name">Property name</param>
Public Sub OnPropertyChanged(ByVal Name As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(Name))
End Sub
End Class
Conclusion
I hope you
enjoyed learning about how to update WinForms GridGroupingControl when value
change in datasource.
You can refer
to our WinForms GridGroupingControl feature tour page to know
about its other groundbreaking feature representations. You can also
explore our WinForms GridGroupingControl documentation to
understand how to create and manipulate data.
For current
customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our
30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!