问题描述
根据规范( http://msdn.microsoft.com/en-us/library/k63c05yf.aspx )
文本框应具有 autosize
属性.
当您输入 TextBox1.AutoSize = true
时,它实际上并没有中断.但是,它似乎没有出现在IntelliSense属性列表中.
And it actually doesn't break when you type in TextBox1.AutoSize = true
. However, it doesn't seem to appear in the list of IntelliSense properties.
这是为什么?
我已经尝试过重新编译,并且都可以编译,但是 textbox.autosize
属性从不出现.
I have tried recompiling and it all compiles, but the textbox.autosize
property never appears.
推荐答案
TextBox的AutoSize属性始终为true,这是由构造函数强制执行的.该属性隐藏在父类(TextBoxBase)中,以避免意外将其设置为false.它具有[Browsable(false)]可以将其隐藏在属性网格中,具有[EditorBrowsable(EditorBrowsableState.Never)]可以将其隐藏在IntelliSense弹出窗口中.您可以更改它:
The AutoSize property for TextBox is always true, forced by the constructor. The property is hidden in the parent class (TextBoxBase) to avoid accidentally setting it to false. It has [Browsable(false)] to hide it in the property grid, to hide it in the IntelliSense popup window. You can change it however:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
textBox1.AutoSize = false;
textBox1.Height += 10;
}
}
是的,看起来不太好.现在您知道为什么它被隐藏了.
Yes, doesn't look great. Now you know why it is hidden.
这篇关于为什么Windows Form TextBox中的AutoSize属性没有出现在IntelliSense中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!