469,926 Members | 2,248 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

TreeView SelectedNodeStyle and HideSelection Properties

I’m having a couple of problems using the TreeView control on a windows form.
I feel as if I’m missing something very obvious, but I not seeing it! Any
suggestions would be appreciated.

1. I’d like to change the background color of the selected treeview node.
To do this it looks as if I need to change the treeview’s SelectedNodeStyle
property. MSDN states that “this property is read-only; however, you can set
the properties of the TreeNodeStyle object it returns.” So my first step is
to retrieve the current SelectedNodeStyle so I can modify it. I’m trying to
do that with the following code:

Dim myTreeView As TreeView
Dim currentSelectedNodeStyle As TreeNodeStyle
currentSelectedNodeStyle = myTreeView.SelectedNodeStyle

However the above code results in the following two errors:
Error 1 Type 'TreeNodeStyle' is not defined.
Error 2 'SelectedNodeStyle' is not a member of System.Windows.Forms.TreeView'.

2. When my treeview control looses focus I would like to maintain the
highlighting of the selected node. It appears that this can be accomplished
by setting the following property:

myTreeView.HideSelection = False

However, changing the value of this property either via the treeview’s
property page or programmatically has no effect on the highlighting of the
selected node when myTreeView loses focus; the highlighting disappears if
this property is either True or False.

--
Loren Baker
Jun 27 '08 #1
1 4099
"Loren" <Lo***@discussions.microsoft.comschrieb
I’m having a couple of problems using the TreeView control on a
windows form. I feel as if I’m missing something very obvious, but I
not seeing it! Any suggestions would be appreciated.

1. I’d like to change the background color of the selected treeview
node. To do this it looks as if I need to change the treeview’s
SelectedNodeStyle property. MSDN states that “this property is
read-only; however, you can set the properties of the TreeNodeStyle
object it returns.” So my first step is to retrieve the current
SelectedNodeStyle so I can modify it. I’m trying to do that with the
following code:

Dim myTreeView As TreeView
Dim currentSelectedNodeStyle As TreeNodeStyle
currentSelectedNodeStyle = myTreeView.SelectedNodeStyle

However the above code results in the following two errors:
Error 1 Type 'TreeNodeStyle' is not defined.
Error 2 'SelectedNodeStyle' is not a member of
System.Windows.Forms.TreeView'.

If it is a Winforms app, there is no SelectedNodeStyle property. You
probably mixed up the two controls because there is also a Treeview
control for Web apps.

2. When my treeview control looses focus I would like to maintain
the highlighting of the selected node. It appears that this can be
accomplished by setting the following property:

myTreeView.HideSelection = False

However, changing the value of this property either via the
treeview’s property page or programmatically has no effect on the
highlighting of the selected node when myTreeView loses focus; the
highlighting disappears if this property is either True or False.

I can't answer this one. Maybe it's the color setting chosen in control
panel. Usually, it should work.
Armin

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Peter | last post: by
5 posts views Thread by Dotnet Gruven | last post: by
6 posts views Thread by cyriel1920 | last post: by
reply views Thread by AcuZod | last post: by
reply views Thread by sunny076 | last post: by
1 post views Thread by ton | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.