)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to update the grid while changing the values in underlying datasource in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: September 24, 2016 |
Last Revised Date: December 24, 2019
Tags: update

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));
        }
    }
}

 

VB

''' <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

Samples:

C#: INotifyPropertyChanged

VB: INotifyPropertyChanged

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon