473,854 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView selecting nodes via code

I'm currently using a context menu to allow the user to add, rename and
delete nodes in a treeview control. When a node is added we give it a bogus
name ("NewNode") and invoke the add method. We would then to then select the
newly added node and rename it but can't figure out how to select the node
via code.

How do you select a node from code when you don't know the index?

--
Thanks
Joe
Nov 17 '05 #1
4 24264
treeNode.Select ed = true;

-vj

"JoKur" <Jo*@JoKur.ne t> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
I'm currently using a context menu to allow the user to add, rename and
delete nodes in a treeview control. When a node is added we give it a
bogus
name ("NewNode") and invoke the add method. We would then to then select
the
newly added node and rename it but can't figure out how to select the node
via code.

How do you select a node from code when you don't know the index?

--
Thanks
Joe

Nov 17 '05 #2
Huh?

I'm using ...
(In mouse down event)
mySelectedNode = treeBlocks.GetN odeAt(e.X, e.Y);

(In add sub)
mySelectedNode. Nodes.Add ("New");

where mySelectedNode is a TreeNode

Intellisense doesn't allow mySelectedNode. Selected as you suggest. Can you
be more specific? Also, my question still remains - how does it know which
to select if there are many nodes? You haven't passed it any text or index?

"Vijaye Raji" wrote:
treeNode.Select ed = true;

-vj

"JoKur" <Jo*@JoKur.ne t> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
I'm currently using a context menu to allow the user to add, rename and
delete nodes in a treeview control. When a node is added we give it a
bogus
name ("NewNode") and invoke the add method. We would then to then select
the
newly added node and rename it but can't figure out how to select the node
via code.

How do you select a node from code when you don't know the index?

--
Thanks
Joe


Nov 17 '05 #3
if treeView is of the type TreeView:

treeView.Select edNode = mySelectedNode;

if you want to selected the "New" node, then assign it to a variable:

TreeNode newNode = mySelectedNode. Nodes.Add ("New");
treeView.Select edNode = newNode;

or:

treeView.Select edNode = mySelectedNode. Nodes[0]; // assuming "New" has an index of 0 (zero)

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"JoKur" <Jo*@JoKur.ne t> wrote in message news:53******** *************** ***********@mic rosoft.com...
Huh?

I'm using ...
(In mouse down event)
mySelectedNode = treeBlocks.GetN odeAt(e.X, e.Y);

(In add sub)
mySelectedNode. Nodes.Add ("New");

where mySelectedNode is a TreeNode

Intellisense doesn't allow mySelectedNode. Selected as you suggest. Can you
be more specific? Also, my question still remains - how does it know which
to select if there are many nodes? You haven't passed it any text or index?

"Vijaye Raji" wrote:
treeNode.Select ed = true;

-vj

"JoKur" <Jo*@JoKur.ne t> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
> I'm currently using a context menu to allow the user to add, rename and
> delete nodes in a treeview control. When a node is added we give it a
> bogus
> name ("NewNode") and invoke the add method. We would then to then select
> the
> newly added node and rename it but can't figure out how to select the node
> via code.
>
> How do you select a node from code when you don't know the index?
>
> --
> Thanks
> Joe


Nov 17 '05 #4
EXCELLENT!

Just what I needed. Thanks Dave!
"Dave" wrote:
if treeView is of the type TreeView:

treeView.Select edNode = mySelectedNode;

if you want to selected the "New" node, then assign it to a variable:

TreeNode newNode = mySelectedNode. Nodes.Add ("New");
treeView.Select edNode = newNode;

or:

treeView.Select edNode = mySelectedNode. Nodes[0]; // assuming "New" has an index of 0 (zero)

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"JoKur" <Jo*@JoKur.ne t> wrote in message news:53******** *************** ***********@mic rosoft.com...
Huh?

I'm using ...
(In mouse down event)
mySelectedNode = treeBlocks.GetN odeAt(e.X, e.Y);

(In add sub)
mySelectedNode. Nodes.Add ("New");

where mySelectedNode is a TreeNode

Intellisense doesn't allow mySelectedNode. Selected as you suggest. Can you
be more specific? Also, my question still remains - how does it know which
to select if there are many nodes? You haven't passed it any text or index?

"Vijaye Raji" wrote:
treeNode.Select ed = true;

-vj

"JoKur" <Jo*@JoKur.ne t> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
> I'm currently using a context menu to allow the user to add, rename and
> delete nodes in a treeview control. When a node is added we give it a
> bogus
> name ("NewNode") and invoke the add method. We would then to then select
> the
> newly added node and rename it but can't figure out how to select the node
> via code.
>
> How do you select a node from code when you don't know the index?
>
> --
> Thanks
> Joe


Nov 17 '05 #5

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

Similar topics

1
1754
by: Stefan | last post by:
Hey guys ! Can someone pls help me and tell me how it is possible to Select a Node in 2nd row? I got a treeview which is build like follows: node2.Nodes.Add("blah", "blubb"); node1.Nodes.Add(node2);
14
15110
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
2
7507
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView nodes. The TreeView populates dynamically as there are a significant number of nodes. The DataGrid displays both the items and the nodes from the TreeView. Using the explorer analogy this means the TreeView shows folders, and the DataGrid folders...
4
6936
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 |__ cover type
8
12790
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the form. I only want to allow single selection, so using checkboxes is out of the question. It works as is, but it makes the form very cumbersome if every time that a user selects a node, the whole page has to reload. Is there a way to have a node...
2
1295
by: CraigMuckleston | last post by:
I have a Treeview Control on my Windows Form with a directory structure, ie a list of nodes. This is actually a directory listing from my c drive (similiar to Windows Exlorer). I can iterate through all the foldernames as in the code below, but how can I detect filenames that are held within the folders? Private Sub PrintRecursive(ByVal n As TreeNode) System.Diagnostics.Debug.WriteLine(n.Text) MessageBox.Show(n.Text) ...
6
11976
by: xla76 | last post by:
I have a simple treeview (treeview1) to which I have added two nodes (nodeA and nodeB) which have n levels of child nodes. What I want is to be able to identify whether the child node I select is under NodeA or NodeB. I can do this by splitting the selectednode.fullpath of the child node but there must be a better way. Can any kind soul can enlighten me?
2
4072
by: dav61000 | last post by:
I am new to VB.net so I am not sure if there is a good way to do this or not but here is my problem. I have created a form with a TreeView control on it. When the user selects a node from the treeview I would like to use the AFTER_SELECT method to bring up a new form if possible containing a dataset for the record selected. OR as an alternative I would like to bring up a dataset for that record selected on the same form. I have succeeding in...
0
3318
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. Provide following view properties to listview, through View menu a. Tile b. Icon
0
9750
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11023
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10672
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10740
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9509
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7909
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4147
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.