Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right align text inside a TextBox

I would expect there would be a property that I need to set to align the text inside a TextBox, but I can't find it. I remember using [style="text-align:right"] in ASP.net, but what do I use in WinForms?

like image 543
Dr. Greenthumb Avatar asked Jul 11 '12 13:07

Dr. Greenthumb


People also ask

How do I align text in a text box in Excel?

Hold down Shift , click the objects that you want to align, and then click the Shape Format tab. Click Arrange > Align, and select an alignment option. If you displayed the gridlines, you will see that the objects are aligned on the grid.


2 Answers

You can change the TextAlign propety using HorizontalAlignment enumerator. Try something like:

textBox1.TextAlign = HorizontalAlignment.Right;
like image 158
Felipe Oriani Avatar answered Oct 24 '22 23:10

Felipe Oriani


Use the Textalign Property. It uses the Horizontal Alignment Enumeration which wil give you Left, Right or Center Alignment.

like image 36
Mark Hall Avatar answered Oct 24 '22 21:10

Mark Hall