Just wondering if there is an easier way to create the layout displayed below with just a groupbox. I currently have to use a label and a groupbox to achieve this look.
Thanks!
Printable View
Just wondering if there is an easier way to create the layout displayed below with just a groupbox. I currently have to use a label and a groupbox to achieve this look.
Thanks!
As The name suggests, a GroupBox is intended to be used to group a number of controls. I don't think that it's illogical that the creators would assume that you would want the inner area of the GroupBox empty so you can place the controls you're grouping inside it. The standard GroupBox does not provide that functionality and fair enough too. There may be a valid reason for your doing it but it would be so unusual that the creators would simply assume that you would do as you are now and use a Label. If you want to change that then you could inherit the GroupBox and override its OnPaint method to draw the Contents of the Text property using GDI+, or else you could create a UserControl that was a Label inside a GroupBox, which you could then add to your forms as a unit.
You mean Title Text is a label and you want it drawn directly on the GroupBox? You can probably do it fairly easily with the Paint event of the GroupBox using e.Graphics.DrawText. I'm not a GDI expert, so I'm not sure how you could center the text or position it correctly no matter font sizes or whatever, but it seems feasible.
I come from an electrical engineering background, so I am not familiar with GDI drawing. I would very much like to create a user control that inherits a groupbox with the layout as displayed in the image above. I would like the GroupBox1.Text = "TitleBlock" to be positioned as seen in the image above. Any advice/suggested reading would be appreciated!