views:

95

answers:

3

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?

+1  A: 

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).

Marc Gravell
My guess for "why Browsable(false)" is that it makes sense only when TreeViewNodeSorter is set, which can't be done in the property grid. Doesn't explain why it's hidden from Intellisense though, unless they're just trying to get people to use the Sort() method instead.
itowlson
Thank you. D'oh.
Uros Calakovic
+1  A: 

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.

itowlson
+1  A: 

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.

Hans Passant