TAdvNavBar v2.0.1.1
RAD Studio 2009
Hi,
I am having problems trying to free several dynamically created TAdvNavBarPanels. I am using the following code:
aAdvNavBarPanel.AdvNavbar.RemovePanel(aAdvNavbarPanel.PanelIndex);
This works fine for the first panel. Subsequent calls to this fail with Access Violation. I have traced through and it seems that the PanelIndex is not being updated for the remaining panels.
For example, I have 3 Panels with PanelIndex of 0,1 and 2 respectively. I use RemovePanel(1) and I should expect to have remaining panels, 0 and 1. But I actually have 0 and 2. So when I have to free the next panel (which has PanelIndex=2) I get an access violation as there is no panel 2.
So it seems that RemovePanel is not updating the remaining PanelIndex properties.
My workaround is:
aAdvNavbarPanel.AdvNavBar := nil;
FreeAndNil(aAdvNavbarPanel);
which seems to be working okay. Is this the best way?
Thanks
Stuart