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

57,207

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.

Share:
57,207

Related videos on Youtube

awright18
Author by

awright18

C# .NET programmer, SQL Server DBA, @awright18 on twitter. I love to solve problems in code and in business.

Updated on August 11, 2021

Comments

  • awright18
    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
      Brook over 12 years
      Make the textbox multiline and it will allow you to set the height.
  • awright18
    awright18 over 12 years
    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!
  • nick
    nick about 5 years
    What if I want to have padding inside?
  • bonny
    bonny about 5 years
    Padding like font padding? Like the space between the textbox line and first character?
  • nick
    nick about 5 years
    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)?
  • bonny
    bonny about 5 years
    @nick Try this.Link
  • nick
    nick about 5 years
    Yeah I saw that, but it's got to be so haaard? Why couldn't they just add a TextBox padding property? :(
  • bonny
    bonny about 5 years
    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.
  • Peter Duniho
    Peter Duniho almost 3 years
    This answer offers nothing additional. It is virtually copy/paste from the accepted answer, and is not useful at all.