I have used a user control as a base class (let's call it BaseUC) with 3 labels (in 3 lines) on it (they are set as protected).
And there is another user control that inherits from it (InheritedUC). I have added two more labels in InheritedUC, which are positioned between the base's labels (so there are 5 lines).
Everything is fine is Visiual Studio's design UI view. But when I run the application, labels on BaseUC overlap with the ones in InheritedUC and I can't see the ones on the inherited control.
Any ideas to fix this? Thank you very much
From MSDN: Control.Anchor Property
Use the Anchor property to define how a control is automatically resized as its parent control is resized. Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.
You can anchor a control to one or more edges of its container. For example, if you have a Form with a Button whose Anchor property value is set to Top and Bottom, the Button is stretched to maintain the anchored distance to the top and bottom edges of the Form as the Height of the Form is increased.
Set the Anchor property on all labels: For example:
label1.Anchor = AnchorStyles.Top | AnchorStyles.Left;
If you put your controls in a FlowLayoutPanel
and set the following options:
AutoScroll = True
FlowDirection = TopDown
WrapContents = False
Then you should get panel that will grow and shrink as your controls are added or removed.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With