25

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.

awright18
  • 2,255
  • 2
  • 23
  • 22

3 Answers3

40

You need to set TextBox.Multiline property as true .

TextBox1.Multiline = true;
boop_the_snoot
  • 3,209
  • 4
  • 33
  • 44
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
  • 6
    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! – awright18 Jan 04 '12 at 03:20
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.

bonny
  • 688
  • 1
  • 14
  • 33
  • What if I want to have padding inside? – nick Apr 29 '19 at 11:37
  • Padding like font padding? Like the space between the textbox line and first character? – bonny Apr 29 '19 at 12:07
  • 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)? – nick Apr 29 '19 at 12:08
  • @nick Try this.[Link](https://stackoverflow.com/questions/4903083/textbox-padding) – bonny Apr 29 '19 at 12:09
  • 1
    Yeah I saw that, but it's got to be so haaard? Why couldn't they just add a TextBox padding property? :( – nick Apr 29 '19 at 12:28
  • 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. – bonny Apr 29 '19 at 12:44
-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.