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

Update Datasource by timer

List<Person> person = this.GetPerson();
myGridGroupControl.DataSource = null;
myGridGroupControl.DataSource = person;

The above is the way I did for databinding. I would like to update content by using timer and calling the above function. But i noticed that it has painting error. 
I was tried to use BeginUpdate, Refresh and EndUpdate these 3 method while doing datasource update. But still fail.

Can you please advice any solution can update the content using timer. Thank you. 

7 Replies

AR Amal Raj U Syncfusion Team September 12, 2016 09:17 AM UTC

Hi Falcon, 

Thanks for using Syncfusion products. 

We have analyzed your scenario. We have created a simple sample to replicate your scenario. Unfortunately we could not able to reproduce the reported issue. Please refer to the attached sample and video of our sample execution. However please refer to the below User guide documentation links to resolve painting issues while high frequency updates, 
 
UG Link 
 
Sample Link 
 
Sample Video 
 
Note 
For more information about updating the Grid with timer, please refer to the below Dashboard sample, 
 
Dashboard Sample Location 
<Install_Location>\Syncfusion\EssentialStudio[Version_Number]\Windows\Grid.Grouping.Windows\Samples\Performance\Real-Time Update Demo 
 
<Installed_Location>\Syncfusion\EssentialStudio\<Version_Number>\Windows\Showcase\Grouping Trader Grid Test Demo 
 
If the above provided sample or replication in the video differs from yours, could you please modify the above sample with your issue reproducible or provide us a sample video of your sample execution? It would be helpful for us to provide solution at the earliest.  
 
Please let us know if we missed anything. 

Regards, 
Amal Raj U. 



FC Falcon CK September 12, 2016 12:11 PM UTC

Hi thank you so much for your resolution, it works perfectly. 

But i noticed that the selection will gone after refresh data source.
in my gridgroupcontrol have following setting.

TableOptions.ListBoxSelectionMode = SelectionMode.One;
TableOptions.SelectionBackColor = Color.RoyalBlue;
SelectionTextColor = Color.White;

Can you please advice any way to remain the selection after content has been updated. If the selection can be remained, please let me know how is the behavior? eg, as follow..

I am selecting row no 3.
Content: Name => Joey

After refreshing, it will still selecting row no 3 ? What if after refreshed, the content name Joey has been moved down to row no 5?
Or it will still selecting Joey even Joey has been moved from row 3 to row 5.

Thank you. 


AR Amal Raj U Syncfusion Team September 13, 2016 04:46 AM UTC

Hi Falcon, 

Thanks for the update. 

By default, when data source for the grid is changed through Data source property of GridGroupingControl, the selected record will be cleared as new data source for the Grid is assigned. If you want to set position of record in a previously selected record, we can set the current cell position by make use of the previous grid’s current cell row index and column index. Please make use of the below code, 

Code Example 
private void button1_Click(object sender, EventArgs e) 
    int colindex, rowIndex; 
    colindex = this.gridGroupingControl1.TableControl.CurrentCell.ColIndex; 
    rowIndex = this.gridGroupingControl1.TableControl.CurrentCell.RowIndex; 
    if (this.button1.Text == "Update Data1"
    { 
        this.gridGroupingControl1.DataSource = data2; 
        this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(rowIndex, colindex, GridSetCurrentCellOptions.SetFocus); 
        this.button1.Text = "Update Data2"
    } 
    else 
    { 
        this.gridGroupingControl1.DataSource = data1; 
        this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(rowIndex, colindex, GridSetCurrentCellOptions.SetFocus); 
       this.button1.Text = "Update Data1"
    } 

Sample Link 

If the provided solution doesn’t meet your requirement, please let us know. 

Regards, 
Amal Raj U. 



FC Falcon CK September 13, 2016 01:59 PM UTC

Hi, thank you so much for your code.

Besides that, is there anyway, I can select the code based on the value?? search around each rows and column and look for the one I would like to make selection, after or during data binding. 


AR Amal Raj U Syncfusion Team September 14, 2016 01:17 PM UTC

Hi Falcon, 
 
Thanks for your update. 
 
We have analyzed your scenario. The reported scenario of making current cell based on the cell value of the record can be achieved by looping through Table.Records collection. The expected record can also be set as current record through Record.SetCurrent() method also. Please make use of the below code, 
 
Code Example 
foreach (Record record in this.gridGroupingControl1.Table.Records) 
{ 
    int idValue; 
    if (int.TryParse(record["ID"].ToString(), out idValue)) 
    { 
        if (idValue == 1) 
        { 
            rowIndex = record.GetRowIndex(); 
            colindex = this.gridGroupingControl1.TableDescriptor.NameToField("ID"); 
            //SetCurrent method can also be used to set the expected record as current record. 
      //record.SetCurrent("ID"); 
            this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(rowIndex, colindex, GridSetCurrentCellOptions.SetFocus); 
            break; 
        } 
    } 
} 
 
Sample Link 
 
Regards, 
Amal Raj U. 



FC Falcon CK September 14, 2016 01:55 PM UTC

Awesome, thank you so much !! 


MG Mohanraj Gunasekaran Syncfusion Team September 15, 2016 04:42 AM UTC

Hi Falcon, 
 
Thanks for your update. 
 
We are glad to know that your reported problem has been resolved. Please let us know if you need any further assistance. 
 
Regards, 
Mohanraj G. 


Loader.
Up arrow icon