Getting row column data into the grid after original databinding operation

3 posts, 1 answers
  1. Sunil
    Sunil avatar
    230 posts
    Member since:
    Jan 2004

    Posted 26 Dec 2010 Link to this post

    The data-binding of a grid is done  and then at a later point of time some of the missing values in original data become known.
    How would I refresh the grid so the missing values show up in the grid? One way seems to be to re-bind the grid, but I think there might be a better approach.
    As an example, a grid has a datasource of List<MyCar>.  But, when the original databinding is done,the car price and car depreciation are missing for each MyCar row.. These missing values are available later on, much after the original data-binding operation. The class MyCar is as listed below.
    I am using Q1 2008 SP1 version of Winforms RadControls.

    Thanks
    Sunil

    public class MyCar
        {
            private string _carOwner;
            private string _carModel;
            private int _carYear;
            private string _carColor;
            private double _carPrice;
            private double _carDepreciation;
     
            public MyCar(string carOwner, string carModel, int carYear, string carColor, double carPrice, double carDepreciation)
            {
                CarOwner = carOwner;
                CarModel = carModel;
                CarYear = carYear;
                CarColor = carColor;
                CarPrice = carPrice;
                CarDepreciation = carDepreciation;
            }
            public string CarOwner
            {
                get { return _carOwner; }
                set { _carOwner = value; }
            }
            public string CarModel
            {
                get { return _carModel; }
                set { _carModel = value; }
            }
            public int CarYear
            {
                get { return _carYear; }
                set { _carYear = value; }
            }
            public string CarColor
            {
                get { return _carColor; }
                set { _carColor = value; }
            }
            public double CarPrice
            {
                get { return _carPrice; }
                set { _carPrice = value; }
            }
            public double CarDepreciation
            {
                get { return _carDepreciation; }
                set { _carDepreciation = value; }
            }
     
     
        }
  2. Sunil
    Sunil avatar
    230 posts
    Member since:
    Jan 2004

    Posted 26 Dec 2010 Link to this post

    I think an option would be to implement  'INotifyPropertyChanged' interface for the MyCar class.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 29 Dec 2010 Link to this post

    Hello Sunil,

    Thank you for writing.

    As you already said, you should implement INotifyPropertyChanged interface for your business objects. In addition you have to use BindingList instead of List, or you have to implement the IBindingList interface. Once these requirements are met, RadGridView will be notified when there are changes applied and it will update its UI automatically.

    I hope this information addresses your question. If you have any further questions, do not hesitate to ask.

    Best wishes,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Back to Top