Why can't I alter the height of a TextBox control in the windows forms design view?
Asked Answered
U

3

26

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.

Uird answered 4/1, 2012 at 3:3 Comment(1)
Make the textbox multiline and it will allow you to set the height.Playbook
A
41

You need to set TextBox.Multiline property as true .

TextBox1.Multiline = true;
Attraction answered 4/1, 2012 at 3:17 Comment(1)
Yeah 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!Uird
M
7

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.

Moreland answered 5/1, 2016 at 11:43 Comment(6)
What if I want to have padding inside?Herring
Padding like font padding? Like the space between the textbox line and first character?Moreland
The 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)?Herring
@Herring Try this.LinkMoreland
Yeah I saw that, but it's got to be so haaard? Why couldn't they just add a TextBox padding property? :(Herring
Ya, 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.Moreland
G
-1

To resize height, you will find a drop-down menu. In here, check multiline.

And you can't resize labels at all. They automatically scale to the text.

Geosynclinal answered 10/8, 2021 at 19:20 Comment(1)
You can resize labels though. Just set the Label's property named AutoSize to False.Creamer

© 2022 - 2024 — McMap. All rights reserved.