I can't see the above property neither in the object browser nor in intellisense for TreeView, why is this? I can set in my code though, it and the project builds successfully. When I gight click it and select 'go to definition' it is shown like a public bool property. Is this normal, or have I messed something up?
You can't see it because it is hidden:
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
Normally, the assumption is that it makes sense in a base-class, but isn't supported for the current type TreeView
- but TreeView
inherits from Control
, so I'm not sure what is going on here! In particular, MSDN doesn't make any comments that suggest any reason why it is hidden, unless perhaps it conflicted with the designer (node editor).
The Sorted property is marked with BrowsableAttribute(false)
, which stops it appearing in the property grid, and with EditorBrowsableAttribute(EditorBrowsableState.Never)
, which stops it appearing in Intellisense. So yes, this is normal: for whatever reason, the person who designed that API wanted to discourage you from seeing it.
It is probably hidden because the native Windows tree view control makes this property act flaky. Setting Sorted = false doesn't "unsort" the treeview. It has no effect at all, at least until you add another node. The semantics of the Sort() method are clear. And does the exact same thing as setting Sorted = true.