Discussion of article "DoEasy. Controls (Part 4): Panel control, Padding and Dock parameters"
You are missing trading opportunities:
- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration Log in
If you do not have an account, please register
New article DoEasy. Controls (Part 4): Panel control, Padding and Dock parameters has been published:
In this article, I will implement handling Padding (internal indents/margin on all sides of an element) and Dock parameters (the way an object is located inside its container).
The Panel WinForm object is essentially a regular container for placing other WinForm objects inside it. When placing such objects, we can independently specify the required coordinates for placing an object, so that it is located at the specified coordinates. But we can also specify how to bind the object placed in the container after it has been created inside the container. There are six methods of binding an object inside its container (object's Dock property):
If we select one of the bind methods, in which an object sticks to one or all container borders, its edges are bound to the container border considering the Padding value set for the container — the border of the placed object is not bound to the container border, but is distanced from the container by a distance specified in container Padding value.
The way an object is located inside the container is specified in its Dock value. If the container features more than one object, each subsequent object "sticks" not to the container border at the Padding distance, but to the previous object attracted to the same side of the container.
The image shows how objects in MS Visual Studio are attracted to the top edge of their container having the value of Padding set to 20 if attraction to the top edge of the container is set for them:
In the current article, I will implement all possible options of locating an object inside its one-object container.
In order to consider the Padding value of the container, I will add yet another object on canvas to the Panel object itself to be served as an underlay for placing all the necessary objects inside the panel, rather than shifting the coordinates of the object located inside the panel.
Author: Artyom Trishkin