?
Solved

Centered Text

Posted on 2006-11-27
5
Medium Priority
?
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

752 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