Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
470
Programmatically remove all groups from listbar
posted

Hi,

I have a list bar which I have set to an explorer bar. I need to programmatically remove all the groups in the listbar and then reload the list bar with a different set of groups. I have 14 groups in my listbar and I tried a for next loop trying to remove each group and then a For Each Next loop to remove each group but every time my loop gets to 7 it crashes. I assume it counts down and the indexes change when I remove a group but I am thinking there has got to be an easier way. Any suggestions?

Thanks,
Steve

  • 14517
    Suggested Answer
    Offline posted

    Hi Steve,

    You need to remove the groups in reverse order:

            Group grp = null;
            for (int i = UltraWebListbar1.Groups.Count-1; i >= 0; i--)
            {
                grp = UltraWebListbar1.Groups[i];
                UltraWebListbar1.Groups.Remove(grp);
            }

    Thanks,

    Valerie