473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 4363
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Peter | last post by:
Hello Thanks for reviewing my question. I would like to know how can I programmatically select a node Thanks in Advanc Peter
5
by: Dotnet Gruven | last post by:
With this TreeView declaration: <asp:TreeView ID="Cloner" runat="server" SelectedNodeStyle-Font-Bold="true" SelectedNodeStyle-ForeColor="#003E21" OnTreeNodePopulate="PopulateNode"...
6
by: cyriel1920 | last post by:
Hi, I use the selectednodestyle with a white background so the user can see which item was chosen in the treeview navigation. The nodes have a navigateURL with a target to another frame....
0
by: AcuZod | last post by:
Heyas! Using the TreeView control on a website built in VS 2005, the SelectedNodeStyle.ImgURL setting doesn't seem to work. Here are my settings: ImgSet = "Custom" NodeStyle.ImgURL =...
0
by: sunny076 | last post by:
Hi, In my application, I use treeview inside a frame so when a tree node is clicked, it will direct to the main content only. I have set the selectednodeStyle with BackColor="Yellow", but when I...
4
by: Xenomorph | last post by:
I have a program where you click an item on the TreeView on the left, and then work with whatever pops up on the right. There are many entries on the TreeView, and when you click something on the...
1
by: Falcula | last post by:
Hello, I have a treeview control, when i select a item i navigate to url. But selected node is lost, it reset itself, loosing state. I post my code here. Thanks in advance. <script...
0
by: Falcula | last post by:
Hello, I have a treeview that i fill from a database, when i update nodename in database the treeview dont update. Its works when iam not useing enableviewstate="true" but then i loosing the...
1
by: ton | last post by:
Hi, How can I limit the size of a treeview on a webform so the user can scroll on its page. I've allready placed the control in a DIV like: <div style="OVERFLOW:auto; WIDTH:100%;...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.