Why the AutoSize Property in the Windows FormBox Text Box Does Not Display in IntelliSense

According to the specifications ( http://msdn.microsoft.com/en-us/library/k63c05yf.aspx )

Text fields in Windows Forms must have the autosize property.

And it doesn’t actually break when you enter TextBox1.AutoSize = true . However, it does not appear in the IntelliSense property list.

Why is this?

I tried to recompile and it all textbox.autosize , but the textbox.autosize property never appears.

+6
source share
2 answers

The AutoSize property for a TextBox is always true, called by the constructor. The property is hidden in the parent class (TextBoxBase), so as not to accidentally set it to false. It has [Browsable (false)] to hide it in the [EditorBrowsable (EditorBrowsableState.Never)] property grid to hide it in the IntelliSense popup. However, you can change it:

 public partial class Form1 : Form { public Form1() { InitializeComponent(); textBox1.AutoSize = false; textBox1.Height += 10; } } 

Yes, it looks great. Now you know why it is hidden.

+10
source

The Control.AutoSize property (and its override in TextBoxBase ) is declared with the following attribute:

 [EditorBrowsable(EditorBrowsableState.Never)] 

IntelliSense uses this property to decide not to display the property in the completion list.

(I don’t know enough about Windows Forms to say why this property is marked as inaccessible for viewing.)

+1
source

Source: https://habr.com/ru/post/886074/


All Articles