Results 1 to 9 of 9

Thread: how to center the groupbox text

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    how to center the groupbox text

    I want to align my groupbox title to center, not the default "left", how can I do it? Thanks.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: how to center the groupbox text

    You can't.

    Have a nice day.

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: how to center the groupbox text

    PS, unless you do one of the following:

    1. Inherit from Groupbox (or panel) and override the paint method.

    2. Insert a bunch of whitespace to shove the text along a bit.

    3. Write your own control from scratch.
    I don't live here any more.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    Re: how to center the groupbox text

    thanks. That sounds complicated. Do you have sample code to help?

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: how to center the groupbox text

    Afraid not, sorry. Maybe someone else has tackled this before.

    Anyone?
    I don't live here any more.

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

    Re: how to center the groupbox text

    It's a bit of a hack but an easy way is to not enter any text for the GroupBox and then just put a Label where you want the text to be. Note that you must make sure that the label's parent control is the form and not the group box or it will not display properly. You could create a UserControl that includes a GroupBox and a Label that will handle the positioning of the label automatically. I use a similar method to appear to include a CheckBox in the text of the group box.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    Re: how to center the groupbox text

    Thanks.

  8. #8
    Registered User
    Join Date
    Oct 2021
    Posts
    1

    Re: how to center the groupbox text

    Quote Originally Posted by Palmtree View Post
    I want to align my groupbox title to center, not the default "left", how can I do it? Thanks.
    Try space it " Camera1", it will work.

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: how to center the groupbox text

    Quote Originally Posted by palanimaa View Post
    Try space it " Camera1", it will work.
    It leaves an incomplete border space before the title text. JMcilhinney's suggestion will work

    Attachment 182850

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