Reputation: 37
Is there a way i can make my text box's text into the center of the text box when its multi line?
My example is windows 8 login username text box if you haven't seen it Google it I have not provided any example in code because I'm simply new to C#, I have researched it and it said something about grid? But I didn't know where to add it and I also thought it was for vb.net coding language
They all said things like
<TextBox Width="200"
Text="Hello world !"
TextAlignment="Center"/>
But i might sound dumb but I have never seen this in C#, am I looking at a different language? My app is below!!
Upvotes: 0
Views: 105
Reputation: 101681
In WinForms you can set TextBox
's TextAlign
property to Center
like this:
textBox1.TextAlign = HorizontalAlignment.Center;
For multiline TextBoxes there is no property to set vertical alignment,but in Form_Load
you can add some newlines to the TextBox.
For example:
textBox1.Text += String.Join("", Enumerable.Repeat(Environment.NewLine, 5));
This will add 5
new line, you can change the count according to your TextBox
's height.
Upvotes: 2