This is a migrated thread and some comments may be shown as answers.

BindingList() update, grid event question.

3 Answers 863 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 11 Feb 2019, 10:52 PM

     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.

 

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 12 Feb 2019, 01:51 PM
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.
0
Charles
Top achievements
Rank 1
answered on 12 Feb 2019, 04:00 PM

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;

            }

0
Dimitar
Telerik team
answered on 13 Feb 2019, 11:32 AM
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.
Tags
GridView
Asked by
Charles
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Charles
Top achievements
Rank 1
Share this question
or