GroupBar items not clearing out properly

I'm using the GroupBar control in a project where the GroupBarItems are added dynamically in code from a database. The layout consists of a static GroupBar added at design-time with three GroupBarItems. Each item.Client is another GroupBar which as several items of which each item.Client is a ListView. So in essence I have a ListView inside of a GroupBarItem which his inside of another GroupBarItem. It looks something like this:


The problem is, after I update the database and clear the main GroupBar using gbMain.Items.Clear() and then repopulate the GroupBar from the database there are still remnants of the old items. For example, if I go into the database and delete all of the SubBar items and ListView items and then repopulate I get things like this:


It's as if the main GroupBar is not resetting or reinitializing completely. Quitting the program and running it again fixes the issue until I make another change. I've tried calling gbMain.Referesh() and gbMain.Invalidate() after the gbMain.Clear() to force a redraw but it doesn't seem to make a difference. Is there a way to completely clear all of the items our of a GroupBar so I can repopulate?

3 Replies

KR Kannan R Syncfusion Team October 27, 2017 09:10 AM UTC

Hi Anthony 
 
Thank you for contacting Syncfusion support.  
 
In GroupBar control, the GroupBarItems collection will hold all the GroupBarItem and controls that we add will be stored in its Controls collection. So we will need to clear its Control collection and GroupBarItems collection to achieve this requirement. Please make use of below code snippet for your reference. 
 
Code Snippet: [C#] 
 
 
            // To clear GroupBarItems 
            this.groupBar1.GroupBarItems.Clear(); 
            // To clear the loaded controls  
            this.groupBar1.Controls.Clear(); 
 
 
 
Screenshot 
 
With Control added 
 
 
 
With Controls cleared 
 
We have also prepared sample for your reference and it can be downloaded from below location.  
 
Sample: GroupBar_Item 
 
Kindly check with above solution and let us know if it helps. 
 
Regards 
Kannan 



AM Anthony Mott October 27, 2017 06:46 PM UTC

Ah, yes, it worked! That was the piece I was missing.

Thank you!



MK Mallika Kannan Syncfusion Team October 30, 2017 05:28 AM UTC

Hi Anthony 
 
Thanks for your update. 
 
We are glad to hear that we have helped you on this. 
 
Please let us know if you need have any other assistance. 
 
Regards, 
Mallika 
 


Loader.
Up arrow icon