In Windows Forms, when I position a label control at Y=0
inside a groupbox, then the label intersects with the title text on top of the groupbox.
How can I get the usable area within the Groupbox
, i.e. the are that's not obstructed by the title text of the box?
Setting control.Y = groupBox.Padding
.Top doesn't work. And Groupbox.ClientRectangle
doesn't take the text into account either.
Edit: There is an easy hack to get that inner rectangle: Simply position one Label
in the GroupBox
, and set it's Dock
property to Fill. Then you can get the relevant information (Top/Bottom/Left/Right) from the Panel, or simply use the panel directly to add your child controls.
However, I'd still like to know how to get those coordinates without such hacks.