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.
Unfortunately, activation email could not send to your email. Please try again.

Binding to an ObservableCollection Supported??

Thread ID:

Created:

Updated:

Platform:

Replies:

124588 Jun 15,2016 04:03 PM Jun 17,2016 08:30 AM Windows Forms 3
loading
Tags: GridGroupingControl
Jeff Voigt
Asked On June 15, 2016 04:03 PM

I was doing this in WPF but it doesn't seem to work in windows forms.  Is this supported for the latest version of Syncfusion / GridGroupingControl?  I'm setting my data source to an empty ObservableCollection<ViewRecord> that is later filled, but the UI does not refresh while items are added...

Thanks,
-jeff

Amresh S [Syncfusion]
Replied On June 16, 2016 09:03 AM

Hi Jeff, 

Thank you for using Syncfusion products. 

We had analyzed your reported query in our end and couldn’t be able to reproduce the issue. Here we have provided the simple sample. In the below sample, grid can be updated once the data is added to the observable collection.  
Please refer the below attached sample for assigning the observable collection values dynamically to the grid cells. If still the issue persists, please provide us with a minimal sample or the code snippet used for assigning the dynamically added items to the grid. 

Sample: 

Regards, 
Amresh S. 


Jeff Voigt
Replied On June 16, 2016 09:18 AM

Not even close.

The example that you provided bindings the grid to an observable collection (yes).  Then when you click the add values button it created a new List<> and rebinds the data (not an observable collection).  This has nothing to do with my original question.  This is what I was trying to accomplish (that I was able to accomplish in WPF).

1) bind grid to an observable collection (could have 1 or 2 rows in it).
2) then click a button that adds a few rows to the observable collection (do not set a new datasource on the grid) and it should automatically update the grid.  That is how it works w/WPF because the grid knows to listen for changes in observable collections.

Look at your example and it does nothing of the sort.

Thanks,
-jv

Piruthiviraj Malaimelraj [Syncfusion]
Replied On June 17, 2016 08:30 AM

Hi Jeff, 
 
Thank you for update. 
 
In order to update the grid with modified ObservableCollection<>  in runtime , TableDirty property of grid and Refresh() method can be used. Please make use of the below code, 
 
Code Snippet: 
//Add the record to ObservableCollection in RunTime. 
private void button1_Click(object sender, EventArgs e) 
{ 
   for (int k = 0; k <= 5; k++) 
   { 
      Random rand = new Random(); 
      int r = rand.Next(100); 
      source.Add(new SampleSrc(r.ToString(), "Category" + r.ToString(), "SampleData" + r.ToString())); 
   } 
   this.gridGroupingControl1.Table.TableDirty = true; 
   this.gridGroupingControl1.Refresh();            
} 
 
Sample Link: 
 
Regards, 
Piruthiviraj 


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.

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.

;