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 make a sfDataGrid cell to blink on value change ?

Thread ID:

Created:

Updated:

Platform:

Replies:

145654 Jul 2,2019 12:20 PM UTC Jul 5,2019 05:35 AM UTC WinForms 5
loading
Tags: SfDataGrid
Luis Francisco
Asked On July 2, 2019 12:20 PM UTC

Hi,

I have a WinForms master-detail grid that is feed/updated by a MQTT stream of data, the data is correctly being displayed as it arrives, however I would like to provide to the user visual feed back of the cell just being update just briefly blinking its background or border, is it possible, like in many other sf controls, to do that ?

Thank you for your superb product and support.

Adhikesevan Kothandaraman [Syncfusion]
Replied On July 3, 2019 01:40 PM UTC

Hi Luis, 

Thanks for using Syncfusion products. 

If you want to update the background color of the updated cell, you can use the QueryCellStyle and RecordPropertyChanged event as like the following code sample, 

Code Snippet: 
this.sfDataGrid1.QueryCellStyle += FirstLevelSourceDataGrid_QueryCellStyle; 
this.sfDataGrid1.View.RecordPropertyChanged += View_RecordPropertyChanged; 
private object rowData = null; 
private string propertyName; 
 
void View_RecordPropertyChanged(object sender, PropertyChangedEventArgs e) 
{ 
    rowData = sender; 
    propertyName = e.PropertyName; 
} 
 
private void FirstLevelSourceDataGrid_QueryCellStyle(object sender, Syncfusion.WinForms.DataGrid.Events.QueryCellStyleEventArgs e) 
{ 
    if (e.Column == null) return; 
 
    if (e.DataRow.RowData == rowData && e.Column.MappingName == propertyName) 
        e.Style.BackColor = Color.Green; 
} 
 
 

Regards, 
Adhi 


Luis Francisco
Replied On July 3, 2019 08:56 PM UTC

Hi,

Thank you, this issue is NOT about how to change the cell background color. The issue is that the DATA CHANGES directly in the ObservableCollection, there I can set a property like  "shall_blink = true", and use it to BLINK-ON the cell on  the QueryCellStyle event.

The real issue now, is how to keep a pointer to that cell, so I can return the cell to its original color AFTER a few milliseconds and BLINK-OFF this cell, as the QueryCellStyleEventArgs does not provide sufficient info to the actual GridCell being painted, so I don´t know how to unpaint it using a delayed Task like in the snipped bellow:

        private void Grid_QueryCellStyle(object sender, QueryCellStyleEventArgs e)
        {
            if ((bool) e.DataRow.RowData.GetPropertyValue("shall_blink"))
            {
                Task.Run(() =>
                {
                    this.BeginInvoke(new Action(BlinkCell), new object[] { e });

                    void BlinkCell(QueryCellStyleEventArgs e2)
                    {
                        Color old_color = e2.Style.BackColor;
                        e2.Style.BackColor = Color.Yellow;
                        Task.Delay(250);
                        e2.Style.BackColor = old_color;
                    }
                });
            }
........



Adhikesevan Kothandaraman [Syncfusion]
Replied On July 4, 2019 01:49 PM UTC

Hi Luis,  

Thanks for your update. 

If you want to change the particular cell value for the SfDataGird, you can use the property changed even and use the timer to update style and reset the properties. Please refer to the following code snippet and sample, 

Code Snippet: 
this.sfDataGrid1.QueryCellStyle += FirstLevelSourceDataGrid_QueryCellStyle; 
this.sfDataGrid1.View.RecordPropertyChanged += View_RecordPropertyChanged; 
propertyChangingTimer.Interval = 2000; 
propertyChangingTimer.Tick += propertyChangingTimer_Tick; 
 
private object rowData = null; 
private string propertyName; 
private Timer propertyChangingTimer = new Timer(); 
void View_RecordPropertyChanged(object sender, PropertyChangedEventArgs e) 
{ 
    rowData = sender; 
    propertyName = e.PropertyName; 
    propertyChangingTimer.Start(); 
} 
 
void propertyChangingTimer_Tick(object sender, EventArgs e) 
{ 
    propertyChangingTimer.Stop(); 
 
    //Reset the properties on the timer tick. 
    propertyName = string.Empty; 
    rowData = null; 
    this.sfDataGrid1.TableControl.Invalidate(); 
} 
 
private void FirstLevelSourceDataGrid_QueryCellStyle(object sender, Syncfusion.WinForms.DataGrid.Events.QueryCellStyleEventArgs e) 
{ 
    if (e.Column == null) return; 
 
    if (e.DataRow.RowData == rowData && e.Column.MappingName == propertyName) 
        e.Style.BackColor = Color.Green; 
} 

 

Regards, 
Adhi 



Luis Francisco
Replied On July 4, 2019 03:42 PM UTC

Perfect !!! Thank you so much.

Farjana Parveen Ayubb [Syncfusion]
Replied On July 5, 2019 05:35 AM UTC

Hi Luis, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Farjana Parveen A 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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