为什么我不能在Windows窗体设计视图中更改TextBox控件的高度?

时间:2021-07-30 21:11:09

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.

我有一个新项目。我删除了一个文本框控件。我打开属性窗口,我可以更改高度并点击输入或单击开箱即可更新设计器,但当我尝试更改高度时,它会重置为默认值。这是为什么?我对Label有同样的问题,但我关闭了AutoSize,它允许我修改值。是否有一些属性可以关闭,以便能够在设计视图中修改文本框的高度?我正在使用Visual Studio 2010 sp1。我在Visual Studio 2008中遇到了同样的问题。我是Windows窗体的新手。

2 个解决方案

#1


22  

You need to set TextBox.Multiline property as true .

您需要将TextBox.Multiline属性设置为true。

TextBox1.Multiline = true;

#2


1  

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.

检查Multiline将允许调整大小,但它也允许在文本框中输入(返回)键。非多行TextBox的高度由Font的大小确定。减少到文本框字体大小,TextBox将自动调整大小。

#1


22  

You need to set TextBox.Multiline property as true .

您需要将TextBox.Multiline属性设置为true。

TextBox1.Multiline = true;

#2


1  

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.

检查Multiline将允许调整大小,但它也允许在文本框中输入(返回)键。非多行TextBox的高度由Font的大小确定。减少到文本框字体大小,TextBox将自动调整大小。