Results 1 to 4 of 4

Thread: [2005] How To Display GroupBox Text Over Outline?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    65

    [2005] How To Display GroupBox Text Over Outline?

    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!
    Attached Images Attached Images  

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] How To Display GroupBox Text Over Outline?

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Lively Member
    Join Date
    Jun 2006
    Location
    City of Angles. Right Angles.
    Posts
    110

    Re: [2005] How To Display GroupBox Text Over Outline?

    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.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    65

    Re: [2005] How To Display GroupBox Text Over Outline?

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width