Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Vertically centering text in a label field

In a userform, I sometimes prefer using a label instead of a textbox, because the label can't be edited and is automatically gray. Basically I want to use the label field just as if it were a textbox that can't be edited and is always grayed out.

The problem I have is that the caption (font) in the label is not centered vertically in the box. It looks to be aligned at the top, and I can't see any way to change it. Maybe not a big deal, but the letters don't line up with other textboxes on the same line and it makes the userform look bad.

Does anyone know how I can center the label caption vertically within the label field?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Vertically centering text in a label field

mondrogan laid this down on his screen :
In a userform, I sometimes prefer using a label instead of a textbox, because
the label can't be edited and is automatically gray. Basically I want to use
the label field just as if it were a textbox that can't be edited and is
always grayed out.

The problem I have is that the caption (font) in the label is not centered
vertically in the box. It looks to be aligned at the top, and I can't see any
way to change it. Maybe not a big deal, but the letters don't line up with
other textboxes on the same line and it makes the userform look bad.

Does anyone know how I can center the label caption vertically within the
label field?


Why not use a textbox that has its 'Enabled' property set to 'False'?

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Vertically centering text in a label field

Would adjusting the text font size and/or height property of the label
suffice?
Changing those properties may give the text the "appearance" of being
centered.

MB

"mondrogan" wrote in message
...
In a userform, I sometimes prefer using a label instead of a textbox,
because the label can't be edited and is automatically gray. Basically I
want to use the label field just as if it were a textbox that can't be
edited and is always grayed out.

The problem I have is that the caption (font) in the label is not centered
vertically in the box. It looks to be aligned at the top, and I can't see
any way to change it. Maybe not a big deal, but the letters don't line up
with other textboxes on the same line and it makes the userform look bad.

Does anyone know how I can center the label caption vertically within the
label field?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Vertically centering text in a label field

In a userform, I sometimes prefer using a label instead
of a textbox, because the label can't be edited and is
automatically gray. Basically I want to use the label
field just as if it were a textbox that can't be edited
and is always grayed out.

The problem I have is that the caption (font) in the
label is not centered vertically in the box. It looks to
be aligned at the top, and I can't see any way to
change it. Maybe not a big deal, but the letters don't
line up with other textboxes on the same line and it
makes the userform look bad.

Does anyone know how I can center the label caption
vertically within the label field?


You can fake centering the text in the label vertically by using two Label
controls having the same fill color. Set Label1 to have a border and set its
Caption to the empty string. Next, set Label2 to not have a border and put
the text you want to display in its Caption property. Also set Label2's
AutoSize property to True and then place Label2 over top of Label1 so its is
located where you want it horizontally. You can center it vertically using
this code...

Label2.Top = Label1.Top + (Label1.Height - Label2.Height) / 2

but do so after you place the text you want to display in Label2. If you do
everything correctly, then the text you put in Label2 will look as if it is
part of Label1 and be located where you want it.

Rick Rothstein (MVP - Excel)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
centering text on textbox Alberto Ast[_2_] Excel Programming 5 January 14th 10 11:14 PM
text centering AlanW Excel Programming 1 September 1st 07 08:22 AM
Centralizing Vertically of Label and TextBox zhj23 Excel Programming 0 March 2nd 06 03:28 PM
Centering the text in a message box Rob_T Excel Programming 2 October 10th 04 01:12 AM
Centering the text in a message box Rob_T Excel Programming 4 October 8th 04 10:02 AM


All times are GMT +1. The time now is 02:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"