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. Image for the cookie policy date

Flickering when refresh grid grouping control

Hi support

I am having 2 issues for the following setting.

1. The GGC is Flickering when doing refresh job

2.  When there is few hundred line of data in the grid, it will hang and showing Not Responding, I have to restart the system.

Check the code as below. 

// Grid setting function 

ggc_mygrid.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
ggc_mygrid.TableOptions.ListBoxSelectionMode = SelectionMode.One;
ggc_mygrid.TableOptions.SelectionBackColor = Color.RoyalBlue;
ggc_mygrid.TableOptions.SelectionTextColor = Color.White;
for (int a = 0; a < 15; a++)
{
ggc_mygrid.TableDescriptor.Columns[a].Appearance.AnyRecordFieldCell.Font.Bold = true;

if (a < 3)
{
ggc_mygrid.TableDescriptor.Columns[a].Appearance.AnyRecordFieldCell.TextColor = Color.White;
}
else
{
ggc_mygrid.TableDescriptor.Columns[a].Appearance.AnyRecordFieldCell.TextColor = Color.Lime;
ggc_mygrid.TableDescriptor.Columns[a].Appearance.AnyRecordFieldCell.HorizontalAlignment = Syncfusion.Windows.Forms.Grid.GridHorizontalAlignment.Center;
}
}
ggc_mygrid.TableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.BackColor = Color.SkyBlue;
ggc_mygrid.TableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.TextColor = Color.Black;
ggc_mygrid.TableDescriptor.Columns[6].Appearance.AnyRecordFieldCell.BackColor = Color.SkyBlue;
ggc_mygrid.TableDescriptor.Columns[6].Appearance.AnyRecordFieldCell.TextColor = Color.Black;

ggc_mygrid.TableDescriptor.Columns[9].Appearance.AnyRecordFieldCell.TextColor = Color.FromArgb(245, 144, 36);
ggc_mygrid.TableDescriptor.Columns[10].Appearance.AnyRecordFieldCell.TextColor = Color.FromArgb(245, 144, 36);

ggc_mygrid.TableControlCurrentCellStartEditing += ggc_mygrid_TableControlCurrentCellStartEditing;
ggc_mygrid.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2010Black;

GridConditionalFormatDescriptor gridCondFormat = new GridConditionalFormatDescriptor();
gridCondFormat.Appearance.AnyRecordFieldCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.Black);                
gridCondFormat.Appearance.AnyRecordFieldCell.Enabled = false;
gridCondFormat.Expression = "[StyleId] = 1";

GridConditionalFormatDescriptor gridCondFormat2 = new GridConditionalFormatDescriptor();                
gridCondFormat2.Appearance.AnyRecordFieldCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(33, 38, 57));                
gridCondFormat2.Appearance.AnyRecordFieldCell.Enabled = false;
gridCondFormat2.Expression = "[StyleId] = 2";

ggc_mygrid.TableDescriptor.ConditionalFormats.Add(gridCondFormat);
ggc_mygrid.TableDescriptor.ConditionalFormats.Add(gridCondFormat2);

ggc_mygrid.TableModel.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Table(), Syncfusion.Windows.Forms.Grid.GridResizeToFitOptions.IncludeHeaders);
ggc_mygrid.TableOptions.AllowSortColumns = false;


// refresh function
ggc_mygrid.DataSource = null;
ggc_mygrid.DataSource = todayList;

// Each time refresh will run the Grid setting function again


9 Replies

MG Mohanraj Gunasekaran Syncfusion Team February 21, 2017 02:04 PM UTC

Hi Falcon, 

Thanks for using Syncfusion products. 

Please find your responses in below table. 

Query 
Solution 
Query1: 
The GGC is Flickering when doing refresh job 

We have analyzed your provided code part. You have set the datasource as null while performing the refresh function. If you want to make the changes in same datasource please use the IBindingList to make the changes it will avoid to initialize the DataSource and custom settings again for GridGroupingControl. So no need to make the GridSettings again and We have used the BackGround worker to avoid the flickering issue. Please refer the below code example, 

Code example 
if (!backgroundworker.IsBusy) 
    backgroundworker.RunWorkerAsync(); 
 
 
void backgroundworker_DoWork(object sender, DoWorkEventArgs e) 
    for (int i = 0; i < 10000; i++) 
    { 
        var row = r.Next() % 100; 
        for (int col = 1; col < 10; col++) 
        { 
            var colNum = r.Next() % 15; 
            if (table != null
                table.Rows[row][colNum] = r.Next(1000,9000).ToString();// r.Next().ToString(); 
        } 
    } 
    table.AcceptChanges(); 
Query2: 
When there is few hundred line of data in the grid, it will hang and showing Not Responding, I have to restart the system. 
We have tried to reproduce your scenario. But we are unable to reproduce your scenario at our end. Please provide the following details, 

·         Let us know your time interval for updating the GridGroupingControl.  
·         Let us the your bounding datasource type for GridGroupingControl 
·         Please provide your Syncfusion product version details to reproduce your scenario. It will be helpful to provide the solution at the earliest. 
 
 
 

Sample link: GridGroupingControl 

Note: 
Please refer the below KB link to reflect the changes automatically while updating the GridGroupingControl when implementing INotifyPropertyChanged interface in underlying class. 

Please let me know, if you have any concerns. 

Regards, 
Mohanraj G. 



FC Falcon CK February 24, 2017 10:58 AM UTC

Hi check out the attachment for my current version, the flickering effect has gone, but CPU spike to 40 - 50%



Attachment: syncfs_demo_21b546b3.zip


MG Mohanraj Gunasekaran Syncfusion Team February 27, 2017 04:52 PM UTC

Hi Falcon, 

Thanks for your update 

We have analyzed your provided code part. In your code part, you are assigned the same datasource and reset the style customizations in BackGroundWorkker for particular time interval. So it will lead to some memory issues. We suspect that the reason for assigning the datasource in BackgroundWorker is to update the modified record values in data source. 

By default, the BindingList will be automatically updated while modifying the values due to implementing the INotifyPropertyChanged interface. We have modified the sample based on your customization. Please refer to the below code example and the sample,  

Code example 
void backgroundworker_DoWork(object sender, DoWorkEventArgs e) 
    GenerateMyData(); 
Random ran = new Random(); 
private void GenerateMyData() 
    //The below changes automatically reflected in GridGroupingControl datasource so no need to reassign the datasource. 
    BindingList<Data> data = this.gridGroupingControl1.DataSource as BindingList<Data>; 
    if (data != null
    { 
        foreach (Data d in data) 
        { 
            d.Salary = ran.Next(25000, 45000); 
            d.PF = +ran.Next(590, 3452); 
            d.EMI = ran.Next(25000, 45000); 
            d.Column1 = +ran.Next(590, 3452); 
        } 
    } 
 


public class Data : INotifyPropertyChanged 

    //example for property implementation 
        private int salary; 
    public int Salary 
    { 
        get 
        { 
            return this.salary; 
        } 
        set 
        { 
            this.salary = value; 
            OnPropertyChanged("Salary"); 
        } 
    } 


So please let us know if you have any other reason to reset the datasource for GridGroupingCotrol


Screenshot 
 

Sample link: GridGroupingControl 

Regards, 
Mohanraj G 



FC Falcon CK February 28, 2017 05:06 PM UTC

Hi, what if I am not using data table? My system work as follow..

1. Start showing data in grid
private void btnRefresh_Click(object sender, EventArgs e)
{
try
{
BindingList<MyDataBinding> myList = this.GenerateMyData();
ggc_mygrid.DataSource = null;
ggc_mygrid.DataSource = myList;

this.MyGridSetting();
ggc_mygrid.Update();
myTimer.Interval = 20000;
myTimer.Start();
}
catch (Exception ex)
{
util.Logger(ex.Message + ", " + ex.StackTrace);
}
}



2. Then timer running, at this stage, how to update the data source automatically? 
Currently I am doing as follow.

try
{
BindingList<MyDataBinding> myList = this.GenerateMyData(); // this function is doing some logic and create then arrange the BindingList
ggc_mygrid.DataSource = myList;

this.MyGridSetting();   
}
catch (Exception ex)
{
}


MG Mohanraj Gunasekaran Syncfusion Team March 1, 2017 06:17 PM UTC

Hi Falcon, 

Thanks for the update. 

We have analyzed your code snippet. By default, the datasource will be reflected automatically while updating the BindingList, if INotifyPropertyChanged interface is implemented in that binding list. Please ensure the below things is done in your sample project, 

·         The INotifyPropertyChanged  interface has been implemented in your class as in below image. 

                                                                   

·         Please ensure the PropertyChanged event of INotifyPropertyChanged and OnPropertyChanged method  is defined in your class as in below image 

                                                               

·         Ensure whether the OnPropertyChanged method is invoked in your all fields of the class. 
                                                                          


These above would be more helpful for us to provide the exact solution at the earliest. 

Note: 
If INotifyPropertyChanged   has been implemented in the BindingList, no need to reset the datasource to GridGroupingControl after modified the record values. Also you can perform the insert operation in Bindinglist and this changes also reflected in GridGroupingControl. Please refer to the below code example, 

Code example 
private void GenerateMyData() 
    BindingList<Data> data = this.gridGroupingControl1.DataSource as BindingList<Data>; 
             
    //The below changes auomatically reflected in GridGroupingControl datasource so no need to reassign the datasource. 
    if (data != null
    { 
        foreach (Data d in data) 
        { 
            d.Salary = ran.Next(25000, 45000); 
            d.PF = +ran.Next(590, 3452); 
            d.EMI = ran.Next(25000, 45000); 
            d.Column1 = +ran.Next(590, 3452); 
        } 
 
        data.Insert(5,new Data(ran.Next(20,30).ToString(),"Category0","Description","SampleData","Post",ran.Next(30000,50000),ran.Next(4500,6000),ran.Next(7500,9000),ran.Next(345,789),ran.Next(900,1200))); 
    } 
 
Sample link: GridGroupingControl 
 
If this is differing from your scenario, can you please share your code part of GenerateMyData method operations. It will be helpful provide the exact solution at the earliest. 
 

Regards, 
Mohanraj G. 
 



FC Falcon CK March 3, 2017 05:45 PM UTC

Hi support, would like to know the following code snippet will insert record into grid right? Will generate a row of record right?

data.Insert(5,newData(ran.Next(20,30).ToString(),"Category0","Description","SampleData","Post",ran.Next(30000,50000),ran.Next(4500,6000),ran.Next(7500,9000),ran.Next(345,789),ran.Next(900,1200))); 

My requirement as follow: 
1. Firstly, insert all rows of record into GridGroupingControl
2. Update the grid every interval around 10 seconds.
3. The number of row of records might increase or decrease depend the data source. 
4, When doing updating, cannot have flashing or any others effect, the way I am doing now has no flashing, but the record like reload again each time doing update. It will display from row 1 to row 10 let's say. 

The way I am doing as follow.

When calling GenerateData 

myList = ggc.DataSource as BindingList<MyData>;
myList.Clear();

myList.Add(new MyData(allData));


PM Piruthiviraj Malaimelraj Syncfusion Team March 6, 2017 12:29 PM UTC

Hi Falcon, 
 
Thanks for the update. 
 
We have created the new incident for better followup. Please followup with that incident. 
 
 
Regards, 
Piruthiviraj 



FC Falcon CK March 15, 2017 11:04 AM UTC

Hi sir, I am now follow the way you advice, but when i am updating the source, cpu will spikes for around 20 - 30% and maybe after 10 or 15 mins, the program will hang.

I will need to send you maybe that part of source to you. Easier for you to do debugging, and where and who should I follow up with?


PM Piruthiviraj Malaimelraj Syncfusion Team March 16, 2017 07:23 AM UTC

Hi Falcon, 

Thanks for the update. 

Already we have created the separate incident for your scenario. So you can follow up and provide the details about your scenario also through that incident. We request you  to login to your account by using the below link to see your incident details. 


Regards, 
Piruthiviraj 


Loader.
Up arrow icon