8

I've always wondered why Windows controls have their HideSelection property set to true by default?

Example (TreeView): http://msdn.microsoft.com/en-us//library/system.windows.forms.treeview.hideselection%28v=vs.80%29.aspx

MSDN states that for accessibilty it should be set to false.

Is there any reason to hide the selection to the user by default?

3
  • +1 This has puzzled me as well. One of the first properties to get changed for any list/tree like control. Don't do it quite as quickly for edit/memo controls though. No idea why. Commented Sep 3, 2012 at 11:20
  • 1
    I guess that's just because it's the default in the underlying windows control, TVS_SHOWSELALWAYS / LVS_SHOWSELALWAYS are explicit style flags you have to set. They inherit their default state probably from the ES_NOHIDESEL of the edit control, where this default arguably is the better choice. Incidentally, ListBox didn't have such an option at all, it would always show selection which couldn't be disabled. (except LBS_NOSEL style which prevents any selection at all)
    – peterchen
    Commented Sep 4, 2012 at 8:17
  • re - acessibility: does screen reader treat it differently maybe?
    – peterchen
    Commented Sep 4, 2012 at 8:19

1 Answer 1

3

From your link on the TreeView (MSDN)

Gets or sets a value indicating whether the selected tree node remains highlighted even when the tree view has lost the focus.

If you have multiple TreeViews on a single page, you might want to highlight only the TreeView having focus. Otherwise the user wouldn't know which element is currently selected. But that's the only reason I can think of. Probably this is a designer error of this particular control?

You can test AccessKey in Teleriks Demo page where you get this result:

Screenshot of TreeView Demo

The demo displays the HideSelection property set to false, which I think should be default instead of true, as documentation says. This issue have also been answered on Stackoverflow C# WinForms highlight treenode when treeview doesn’t have focus.

6
  • 1
    You are(were?) able to distinguish a focused from an unfocused treeview selection as an unfocused tree/listview displayed the selection with a shade of grey instead of blue (using default standard theme colors). Have they changed that behavior? If so, that would be rather nonsensical...? Or has Telerik messed with the default color settings for focused/unfocused selections? Commented Sep 3, 2012 at 12:12
  • @MarjanVenema To my knowledge, no. I haven't seen it in any webapp yet - so I think the behavior of default=true is wrong. Commented Sep 3, 2012 at 12:21
  • Hang on, it is a .net control. Which necessitates that it works in a browser on Linux as well. So it can't use the windows native treeview. Which is what I am used to and thus was talking about. The .net control doesn't appear to have any properties to control the color in which the selected node is shown. In that case the default probably should be to hide the selection. Then again how often would you have two or more treeviews on a form? Lists, yes, but trees? Commented Sep 3, 2012 at 17:44
  • @MarjanVenema You're confusing WinForms and ASP.NET here. WinForms uses the native Windows controls AFAIK. Actually this is the same situation as Delphi TListView. ASP.NET is a different story altogether. AFAICS the ASP.NET version doesn't have a HideSelection property: msdn.microsoft.com/en-us/library/… Commented Sep 4, 2012 at 8:24
  • @BennySkogberg The test page you found is about the ASP.NET control, I was asking about the WinForms / native Windows one. Commented Sep 4, 2012 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.