Why can't I alter the height of a TextBox control in the windows forms design view?
Solution 1
You need to set TextBox.Multiline
property as true
.
TextBox1.Multiline = true;
Solution 2
Checking Multiline will allow to resize but it also allows enter(return) key in the textbox.
The Height of a non-Multiline TextBox is fixed by the size of the Font.
Reduce to textbox Font size, the TextBox will resize automatically.
Related videos on Youtube
awright18
C# .NET programmer, SQL Server DBA, @awright18 on twitter. I love to solve problems in code and in business.
Updated on August 11, 2021Comments
-
awright18 almost 3 years
I have a new project. I drop a textbox control on it. I open up the properties window, and I can change the height and hit enter or click out of the box and it will update the designer, but when I try to change the height it resets back to the default value. Why is that? I had the same issue with a Label, but I turned off AutoSize and it allowed me to modify the values. Is there some property I can turn off to be able to modify the Height of a textbox in the design view? I'm using Visual Studio 2010 sp1. I had the same issue in Visual Studio 2008. I am new to Windows forms.
-
Brook over 12 yearsMake the textbox multiline and it will allow you to set the height.
-
-
awright18 over 12 yearsYeah that makes sense. I dind't realize it was actually bound to the Font-size though. If i change the font-size it alters the textbox size which makes perfect sense. I just didn't get it right off the bat. Thanks for your help!
-
nick about 5 yearsWhat if I want to have padding inside?
-
bonny about 5 yearsPadding like font padding? Like the space between the textbox line and first character?
-
nick about 5 yearsThe space between the TextBox border and the text itself, I think it's not possible right (unless you work it around with a panel or smth)?
-
bonny about 5 years@nick Try this.Link
-
nick about 5 yearsYeah I saw that, but it's got to be so haaard? Why couldn't they just add a TextBox padding property? :(
-
bonny about 5 yearsYa, there is nothing easy making font padding in the textbox. However, you can try making a user control and inherit a textbox and make your own textbox. That's hard too but if your pad length is like space then you can design and use your own textbox easily.
-
Peter Duniho almost 3 yearsThis answer offers nothing additional. It is virtually copy/paste from the accepted answer, and is not useful at all.