My old approach to space and align controls and panels on form was to use panels to distance another panel from form edges or another panels, controls. So, I would use a lot of panels for this.
Here is a simple example how I center Panel5 to be distanced, spaced 20px from every form edge:
This works good. And even if I make it very complex, have up 50 spaced, nested panels, it works good, no problems. But the maintenance is a hassle.
So, I 'discovered' AlignWithMargins and now I can center Panel5 like this:
And it works the same, but is much cleaner and a lot less panels.
But, I'm surprised that this property has been there for many many years and I never noticed it. So, before I start changing all the tabs, all the forms, the question is:
Is there anything I'm missing and putting too much pressure on this property to replace 100s of panels - Any obvious case where this doesn't work properly?
I have total 550 panels on main form, probably 80% for this purpose. End user is not affected as they are distributed on 30 Tabs... so, result is clean and working.
EDIT:
Here is most common example how I use Panel to group controls together and can easily move them around, copy&paste and center or align in design or programmatically. Each panel is in grey color.
Is there anything I'm missing and putting too much pressure on this property to replace 100s of panels - Any obvious case where this doesn't work properly?
Yes, you can safely use AlignWithMargins
.
I am using it all the time, and so far haven't had any issues with it. It is far better solution than your spacing panels.