Solved

Centered Text

Posted on 2006-11-27
5
246 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:huji
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 18022120
The best thing to do here is set the width of the label to the width of the panel.
then, centre the text.
0
 
LVL 14

Author Comment

by:huji
ID: 18022174
>> 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?
0
 
LVL 14

Author Comment

by:huji
ID: 18022191
Actually, even this didn't help:

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

0
 
LVL 10

Expert Comment

by:Kinger247
ID: 18022266
You can set it via code in your panel.resize event.

With Label
  .Left=0
  .Top = ??
  .Width = parent.width
  .Height = ??
End with
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 300 total points
ID: 18022421
or you could do it like so :

LabelMonth.TextAlign = ContentAlignment.MiddleCenter
LabelMonth.left= (PanelMonth.width - LabelMonth.width) /2
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now