Solved

How to right align text in a winform label c#

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

11 Experts available now in Live!

Get 1:1 Help Now