Solved

How to right align text in a winform label c#

Posted on 2009-05-08
4
5,870 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
  • 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 85

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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