RadGridView : Refresh problem

11 posts, 0 answers
  1. jv
    jv avatar
    4 posts
    Member since:
    Aug 2012

    Posted 06 Oct 2009 Link to this post

    Hi.

    I'm using RadControls for WinForms Q3 2008 SP2 and i always have problems to refresh the RadGridView.

    I have a class ObjectInfo with some properties.

    I have a form with a RadGridView and a BindingList :

    private BindingList<ObjectInfo> _listObjects;

    In Form1_Load :
    radGrid.DataSource=_listObjects;

    When I change one property of an object of _listObjects, the Refresh method doesn't work, the only way to refresh the GridView is to do :

    radGrid.DataSource = null;
    radGrid.DataSource = _listObjects;

    Is there any other solution ? Because it takes time because there are many rows, rows are formatted with different colors depending on the value of a column (Event RowFormatting), and the grid scrolls on the first row so I have to call the EnsureVisible method because the user can't see anymore the selected row. And also I have to redefine columns (Width, FormatString for Date for example, etc...).

    Thanks.
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 08 Oct 2009 Link to this post

    Hello jv,

    Your ObjectInfo class must implement INotifyPropertyChanged interface to support automatic refresh when used in RadGridView. Please view this example:

    public class OBjectInfo : INotifyPropertyChanged 
        private string name; 
     
        public string Name 
        { 
            get { return name; } 
            set  
            {  
                name = value; 
                this.OnPropertyChanged("Name"); 
            } 
        } 
     
        private void OnPropertyChanged(string propertyName) 
        { 
            this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); 
        } 
     
        protected virtual void OnPropertyChanged(PropertyChangedEventArgs args) 
        { 
            if (this.PropertyChanged != null
            { 
                this.PropertyChanged(this, args); 
            } 
        } 
        #region INotifyPropertyChanged Members 
     
        public event PropertyChangedEventHandler PropertyChanged; 
        #endregion 

    Kind regards,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. jv
    jv avatar
    4 posts
    Member since:
    Aug 2012

    Posted 09 Oct 2009 Link to this post

    It works fine, thanks for the reply.
  5. jv
    jv avatar
    4 posts
    Member since:
    Aug 2012

    Posted 11 Feb 2010 Link to this post

    Hello,

    To avoid implementing INotifyPropertyChanged in all classes and call this.OnPropertyChanged in all set accessors, we finally found an easiest solution : in the CellValueChanged of the RadGridView we only write this :

    RadGridView.ReadOnly = !RadGridView.ReadOnly;
    RadGridView.ReadOnly = !RadGridView.ReadOnly;
  6. Nick
    Admin
    Nick avatar
    767 posts

    Posted 11 Feb 2010 Link to this post

    Hello jv,

    Thank you for contacting us. Unfortunately, while this may work, it is certainly not the best solution as you are actually refreshing the grid using this strange shortcut. If you implement the interface, the refresh will be more accurate and you will gain performance improvement.

    Do not hesitate to write us back if you have further questions.

    Greetings,
    Nick
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Ehab
    Ehab avatar
    2 posts
    Member since:
    May 2012

    Posted 17 Jun 2012 Link to this post

    Hi,

    Why not implementing RefreshData() method in row (like notifing manualy) or somthing like that and make your users life easier ;).
    I dont want implement the INotify in all my classes (DTOs) because I cant (no time) , Pleaaaaaaaaaaaaase give me a work around to force the row or the whole grid to redraw the data.  
    jv work around didnt work for me


  8. Ehab
    Ehab avatar
    2 posts
    Member since:
    May 2012

    Posted 18 Jun 2012 Link to this post

    Hi,

    I  found an elegant work around .
    After updating row data in the data source just call   InvalidateRow() method  from the specific GridViewRowInfo.

    For example:

    (( IssueClass )RadGridView1.CurrentRow.DataBoundItem).Satus= "Resolved" ;
    RadGridView1.CurrentRow.InvalidateRow() ; 







  9. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 20 Jun 2012 Link to this post

    Hi Enab,

    As you found out, in order to update the GridViewRowInfo you can call the InvalidateRow method. Another option is to call the Refresh method of the GridViewTemplate when you want to update all rows in the current view of the RadGridView control.

    All the best,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  10. mostafa
    mostafa avatar
    4 posts
    Member since:
    Mar 2014

    Posted 17 Oct in reply to Julian Benkov Link to this post

    Hi.

    In my case just the selected rowwas changed!!!

  11. Hristo
    Admin
    Hristo avatar
    714 posts

    Posted 18 Oct Link to this post

    Hello Mostafa,

    Thank you for writing.

    Can you please provide me with some details about your actual scenario and the version of the controls you are using? 

    Looking forward to your reply.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
  12. mostafa
    mostafa avatar
    4 posts
    Member since:
    Mar 2014

    Posted 18 Oct in reply to Hristo Link to this post

    Thanks for your reply,

    BindingList Class solved my problem.

Back to Top
UI for WinForms is Visual Studio 2017 Ready