BindingList() update, grid event question.

4 posts, 0 answers
  1. Charles
    Charles avatar
    10 posts
    Member since:
    Mar 2009

    Posted 11 Feb 2019 Link to this post

         I am able to use the bindinglist() as a datasource for my winforms gridview. I set a timer to randomly update an item in my binding list and the changes are correctly reflecting on the grid. I am using the Onpropertychanged and iNotifyPropertyChanged events in my data class, so my grid is updating with the correct values when the underlying data changes.

    I would like to make the cell momentarily change color when the data is changed in that cell. 

    Is there a grid event that fires when the underlying data changes when using a bindinglist and the onpropertychanged notifiers?

    I cannot seem to locate the correct grid event that fires when the data changes.

     

  2. Dimitar
    Admin
    Dimitar avatar
    2913 posts

    Posted 12 Feb 2019 Link to this post

    Hello Chuck,

    You can use the RowsChanged event. The following example shows how you can set the BackColor with this event:
    private void RadGridView1_RowsChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
    {
        if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanged)
        {
            var row = e.NewItems[0] as GridViewRowInfo;
            var cell = row.Cells[e.PropertyName];
            cell.Style.CustomizeFill = true;
            cell.Style.BackColor = Color.Red;
        }
    }

    I hope this helps. Should you have any other questions do not hesitate to ask.
     
    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Charles
    Charles avatar
    10 posts
    Member since:
    Mar 2009

    Posted 12 Feb 2019 in reply to Dimitar Link to this post

    Thanks!

    I was trying to go one step further and get the old value vs the new value to determine if the cell gets a different color. Based on your code, I added to the code below, but was not able to get the old value. Am I using this correctly?

                if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanged)
                {
                    var row = e.NewItems[0] as GridViewRowInfo;
                    var cell = row.Cells[e.PropertyName];
                    
                    cell.Style.CustomizeFill = true;

                    var oRow = e.OldItems[0] as GridViewRowInfo;
                    var oCell = oRow.Cells[e.PropertyName];


                    System.Diagnostics.Debug.Print(oCell.Value + " -> " + cell.Value);
                    
                    cell.Style.BackColor = Color.Red;
                    System.Threading.Thread.Sleep(250);
                    cell.Style.BackColor = Color.White;

                }

  4. Dimitar
    Admin
    Dimitar avatar
    2913 posts

    Posted 13 Feb 2019 Link to this post

    Hello Chuck,

    Your code is ok, it seems that there is an issue with this functionality. I have logged this issue on our Feedback Portal. You can track its progress, subscribe to status changes and add your comment to it here. I have also updated your Telerik Points.

    Unfortunately, due to the nature of the issue, I cannot provide you with a workaround. 

    I hope this helps. Should you have any other questions do not hesitate to ask.
     
    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top