Solved

How to right align text in a winform label c#

Posted on 2009-05-08
4
5,965 Views
Last Modified: 2012-06-27
Hi all,

I've been searching everywhere to find how I can right align text in a label. Found lost of answers for Asp.Net but not for Winforms.
I've tried to play around with the property Text-Align en RightToLeft but no luck. Tried 2 solutions I found on the net but no luck.

I have a bunch of labels wich display currency so they must be right aligned.
vb:         x
vb:      xxx
vb:        xx

Does anyone have an idea how to to this?

Grts
0
Comment
Question by:Pit76
[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
4 Comments
 
LVL 6

Accepted Solution

by:
Cebik earned 250 total points
ID: 24341152
labelCurrency.Autosize = false;
labelCurrency.TextAlign  = TopRight;
0
 
LVL 39

Assisted Solution

by:abel
abel earned 250 total points
ID: 24341159
What you are after is the AutoSize property. Once you set that to False, you can use TextAlign.
0
 
LVL 39

Expert Comment

by:abel
ID: 24341164
right, precisely like Cebik says :)
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24341352
If the "vb:" is part of the string then it'd probably easier to move those into their own labels that are right aligned and then use different labels JUST for the data.  Otherwise you'd have to use a fixed width font and "pad" the string in-between the "vb:" and the data...or use Graphics.MeasureString() to figure out how many spaces are needed to line them up properly with a normal font...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

626 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