Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So I'm using Visual Studio 2005
and I made a multiline texboxt that's shaped as a big rectangle :p
But when I type on it, the text is from Left to right so it looks like the text is just on one side.

How do I center the text?

Thanks in advance!
Posted
Comments
Praveen Raghuvanshi 21-May-14 23:36pm    
try HorizontalContentAlignment and VerticalContentAlignment. Otherwise, customize the DataTemplate. Kindly provide some code for clarification.
Sergey Alexandrovich Kryukov 22-May-14 2:59am    
Vertical?! What data template?! This is not WPF.
—SA
charliedev 22-May-14 20:53pm    
i did not use any code. just made a textbox and typed on it

1 solution

This one is the simple one..

0. Click the textbox.
1. On the right side of your screen, you can see the Solution Explorer and the Properties tab.
2. Kindly search for the Property "Text Align" on the Properties tab.
3. There you are, you can set it if you want it aligned on the left side, right side or on the center.

If you want it to be more complicated (or do it on runtime), you can code it.
This is the code...
VB
textbox1.TextAlign=HorizontalAlignment.Center
 
Share this answer
 
Comments
charliedev 22-May-14 20:54pm    
This is working, thanks :)
Karen Mitchelle 22-May-14 20:56pm    
no problem. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900