In many code examples I have found the DisplayRectangle property of a Control object being used.
However this property does not appear in the intellisense popup, neither does it get any syntax highlighting, but it does compile and work as expected.
Should I use this kind of Property?
How can I find out about more of them, can they be activated in intellisense?
Update/Clarification: I have now found out that it does seem that it depends on which control. The following code does compile:
Control c = sender as Control;
Form f = sender as Form;
PictureBox p = sender as PictureBox;
Console.Write(c.DisplayRectangle); // No Intellisense
Console.Write(f.DisplayRectangle); // Intellisense
Console.Write(p.DisplayRectangle); // No Intellisense
My question was about the DisplayRectangle for PictureBox, or Controls in general.
This is the declaration of the property:
Starting with [Browsable], that attribute ensures that the property doesn’t show up in the Properties window. Which makes sense because it is a runtime property and there is no setter. That’s also the relevance to [DesignerSerializationVisibility], it ensures that the property value doesn’t get written to the InitializeComponent() method. [SRDescription] is for localization.
[EditorBrowsable] is relevant to your question. Using EditorBrowsableState.Advanced ensures that IntelliSense will only display the property if the editor is operating in ‘Show advanced IntelliSense info’ mode. The only IDE that I know that uses this feature is VB.NET, its IntelliSense popup window has an “All” tab but defaults to “Common”. But not the C# IDE, the language you tagged your question with.
I have to guess that you are actually programming in VB.NET, not C#. Click the All tab on the popup.