473,396 Members | 2,076 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,396 software developers and data experts.

[VB 2008] Select a TreeView Node

Hello

I have created a TreeView and i wish to select a node into it
and then expand the selected node.

Is someone has an idea ?

Thanks
Aug 7 '08 #1
5 2760
>I have created a TreeView and i wish to select a node into it
>and then expand the selected node.

Is someone has an idea ?
Assuming you mean a WinForms TreeView control:

yourTreeView.SelectedNode = ...
yourTreeView.SelectedNode.Expand()
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Aug 7 '08 #2
Hi Mattias and thank you for your answer.

But the SelectedNode doesn't select the Node like a user click on it (with a
blue bgcolor)
Is there a solution to do it automatically without setting its BackColor
property to Blue ?
Aug 7 '08 #3
Thanks Kadaitcha Man
but it is not really what i want.

When i write MyTreeView.SelectedNode = myNode, i want the selected Node
myNode is like when we click on it, with the blue bgcolor.
If you have code in the AfterSelect event handler that you want to execute
when you select a node via code then move all the code out of the
AfterSelect handler into another routine. Call the routine from the
AfterSelect handler and call it when you set the SelectedNode in code.
Aug 7 '08 #4
"vino" <al*******@discussions.microsoft.comschrieb:
But the SelectedNode doesn't select the Node like a user click on it (with
a
blue bgcolor)
Is there a solution to do it automatically without setting its BackColor
property to Blue ?
\\\
Me.TreeView1.SelectedNode = ...
Me.TreeView1.Focus()
///

Take a look at the 'HideSelection' property too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Aug 7 '08 #5
Thank you very much Herfried,
it's exactely what i want.
"Herfried K. Wagner [MVP]" wrote:

\\\
Me.TreeView1.SelectedNode = ...
Me.TreeView1.Focus()
///

Take a look at the 'HideSelection' property too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Aug 7 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: someone | last post by:
Here is my code: TreeNodeCollection nodes = tvwFolders.Nodes; if (nodes.Count > 0) { // Select the root node tvwFolders.SelectedNode = nodes; } I hope there is an easier way. I looked at...
4
by: G Uljee | last post by:
How can I find and select an specific item in an treeview control? I want to create a search feature on my treeview. Thanks in advance, Gaby
2
by: Wes | last post by:
I have a treeview that I am continually added nodes to. Each time a new node is added I would like to select that node. Is this possible? I have looked at selectedNode, but I don't know how to...
2
by: Stephen | last post by:
In asp.net 1.1, the IE treeview web control has a property called "SelectExpands" that, when set to true, expands a node when a user clicks the node text. I can't seem to replicate this in the...
13
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the...
4
by: praveen | last post by:
I have a form with treeview control loaded from xml document,text box, two buttons named "Find" and "FindNext" and my treeview which looks like below. Details |__ policy status |__ created by...
4
by: KarlM | last post by:
Hallo! I'm filling my treenode tv with AD-infos with the following code: ____________________________________________________________________ private enum AdImages { AdRoot, Ou, Container,...
3
by: Michael_Burgess | last post by:
Hi there, I've looked around the different groups and still can't figure this out without resorting to scrappy code............ I want to programtically select and highlight a TreeView node,...
4
by: jmDesktop | last post by:
I have searched everywhere and tried several things. I have a treeview with and want to be able to only select a parent node. For example: root //don't want to drag this -parent1 //yes, drag...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.