• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6229
  • Last Modified:

How to right align text in a winform label c#

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
Pit76
Asked:
Pit76
  • 2
2 Solutions
 
CebikCommented:
labelCurrency.Autosize = false;
labelCurrency.TextAlign  = TopRight;
0
 
abelCommented:
What you are after is the AutoSize property. Once you set that to False, you can use TextAlign.
0
 
abelCommented:
right, precisely like Cebik says :)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now