Results 1 to 8 of 8

Thread: center text vertically in label?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    center text vertically in label?

    Hi,

    I need to be able to vertically center the caption in a label. How can this be done? Seems like it might be an API thing...

    Thanks,

    Dan

    Visual Studio 2010

  2. #2
    The Align property? Or do you mean have the letters rotated 90°?

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    I don't believe there is a way to rotate a label...you can have the letters still upright but put newlines between each letter....

    just my $0.02

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by filburt1
    The Align property? Or do you mean have the letters rotated 90°?
    I believe he means like this...

    --------
    Caption

    --------

    that's how a label normally works, he wants...

    --------

    Caption

    --------

    am I right?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Originally posted by SteveCRM
    I don't believe there is a way to rotate a label...you can have the letters still upright but put newlines between each letter....

    just my $0.02
    Steve you can make a custom control to do that if you want to, here is code you could use to do it:

    http://www.vbforums.com/showthread.p...ghlight=rotate

    I think Microbasic has made a control to do it, ask him if you need it.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    crptcblade is correct.

    Also, if the font gets changed, I need the caption to remain horizontally and vertically centered..

    Is this possible?

    Visual Studio 2010

  7. #7
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    hmmm
    i think that this is a little bit less complex than it needs to be. If the 'text' in the label fills less than the label height u could simply set the label to autosize and set its top position to half way (less half the label height) between the designated top and bottom positions.

    Is there some design reason in your form that this approach would not be feasible?
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  8. #8
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    I'm doing it here with 2 labels. Just centering one over the other.
    VB Code:
    1. Private Sub Form_Load()
    2.     With Label1
    3.         .Alignment = vbCenter
    4.         .BorderStyle = vbFixedSingle
    5.     End With
    6.    
    7.     With Label2
    8.         .Width = Label1.Width - 100
    9.         .Left = Label1.Left + 50
    10.         .Top = Label1.Top + ((Label1.Height - .Height) \ 2)
    11.     End With
    12. End Sub

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