Link to home
Start Free TrialLog in
Avatar of huji
hujiFlag for United States of America

asked on

Centered Text

Hello,
I have a panel, inside of which is a label. This label shows the name of a month (e.g. January, May, etc) This month name is changed based on the user input in other fields of the form. What I want to do: To make the label text appear "horizontally centered" in the panel. The default situation is the label's left position is fixed, so with the longer names (like January) the label will expand from the right side. I would like to expand equally from both sides.
Please advise
Huji
Avatar of Kinger247
Kinger247

The best thing to do here is set the width of the label to the width of the panel.
then, centre the text.
Avatar of huji

ASKER

>> The best thing to do here is set the width of the label to the width of the panel.
I can't do that from the properties toolbox of the VS. Should I do this programatically?
Avatar of huji

ASKER

Actually, even this didn't help:

        LabelMonth.Width = PanelMonth.Width
        LabelMonth.TextAlign = ContentAlignment.MiddleCenter

You can set it via code in your panel.resize event.

With Label
  .Left=0
  .Top = ??
  .Width = parent.width
  .Height = ??
End with
ASKER CERTIFIED SOLUTION
Avatar of Mohamed Zedan
Mohamed Zedan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial