المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : UserControl Docking and padding question



C# Programming
05-29-2009, 07:40 PM
I'm editing an existing library of user controls and I must admit, my experience is limited. These user controls are a combination of other user controls, mainly buttons and and panels. They where created to mimic the companies existing controls used in webapps for our desktop applications. Simple, and it works but they where initially designed for limited scalability.

So now the requirement emerges that each control should be resizable without altering the relative position of controls, some of which are transparent. I'm implementing this by, what appeared to be the easy task of reordering controls in the document outline and editing each controls dock and padding properties, which worked fine for a couple of controls.

Now I have the following outline: (control names reduced to simplicity to avoid confusion)


|---UserControl
|---Panel1
|---Panel2
|---Panel3
|---Button1
|---Button2
|---Button3


I dock Panel1 to DockStyle.Fill to the Parent UserControl to ensure that the control is resizable for obvious reasons, My problem is Panel2, which is overlayed on Panel1 by 6 pixels from the left and right respectively, I wish to keep this same fixed distance from the parent despite resizing, so I set dock to Fill and padding for left and right to 6 each, figuring this would work. It doesn't, which makes me feel I misunderstand the usage of Padding to begin with.

Any suggestions on where I went wrong and what would be the proper usage to enable this resizable implementation work as intended?

Sorry for weak explanation / poor ASCII art.

Check out the CodeProject forum Guidelines (http://www.codeproject.com/KB/scrapbook/ForumGuidelines.aspx)[^ (http://www.codeproject.com/KB/scrapbook/ForumGuidelines.aspx)]