160
Bug when docking controls in inherited panel
posted

Hi,

Given the following situation, the order of docking of controls is working incorrectly, whereas docking without using an UltraPanel, or using a Microsoft panel, is working as expected:

Base form has a dock fill UltraPanel, with inside a button docked top.

Both the panel and button are defined protected.

In a derived form we add another button, also docked top.

The newly added button should be shown underneath the docked button from the base class.

At first this looks ok at design time, but at runtime the order of the buttons is reversed. Also closing the design and reopening again already shows that the order of the panels isn't kept: the last added control to the panel is at the top.

In a Microsoft panel, or without using panels, this is solved by designer generated code that like this:

panel1.Controls.SetChildIndex(this.TopButton, 0);
panel1.Controls.SetChildIndex(this.NextTopButton, 0);

The code above is not getting generated when using an UltraPanel, but is when using a Microsoft panel, or no panel at all.

It this a bug in the UltraPanel and/or is there a workaround/fix besides manually adding the lines above to the constructor? I want to see the correct result at design time as well, and not only in code as that would quickly become confusing...

Thanks,

Lieven