473,503 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET TreeView items

I asked this months ago, and never received a reply. Here I go again...

I have a treeview on a Windows Form. I only want to retrieve the top-most
nodes' data from the DB initially. As the user clicks to expand a node, I
will then retrieve its children. Therein lies the problem: I cannot create
a node that displays the plus symbol for the user to click upon.

Can anyone shed some light, please.

Desparate,

Tim
Nov 22 '05 #1
2 1457
The + appears only if the node has children. In your situation, that
condition is not true. I'd suggest you need to cheat a little, ie add in a
dummy child node that is refreshed when the node is selected. Try this as a
starter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.TreeView1.Nodes.Clear()

Me.TreeView1.Nodes.Add("Root Node 1")

Me.TreeView1.Nodes(0).Nodes.Add("DummyNode")

Me.TreeView1.Nodes.Add("Root Node 2")

Me.TreeView1.Nodes(1).Nodes.Add("DummyNode")

Me.TreeView1.Nodes.Add("Root Node 3")

Me.TreeView1.Nodes(2).Nodes.Add("DummyNode")

End Sub

Private Sub GetCorrectChildNodes()

Dim tnRootNode As TreeNode

tnRootNode = Me.TreeView1.SelectedNode

tnRootNode.Nodes.Clear()

Dim tnNewNode As TreeNode

tnNewNode = New TreeNode("Child Node 1")

tnRootNode.Nodes.Add(tnNewNode)

End Sub

Private Sub TreeView1_BeforeExpand(ByVal sender As Object, ByVal e As
System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand

Me.TreeView1.SelectedNode = e.Node

GetCorrectChildNodes()

End Sub


"Tim Wallace" <twallace-ThisDoesNotBelong-AT-emailDOTcom> wrote in message
news:uC**************@TK2MSFTNGP14.phx.gbl...
I asked this months ago, and never received a reply. Here I go again...

I have a treeview on a Windows Form. I only want to retrieve the top-most
nodes' data from the DB initially. As the user clicks to expand a node, I
will then retrieve its children. Therein lies the problem: I cannot
create a node that displays the plus symbol for the user to click upon.

Can anyone shed some light, please.

Desparate,

Tim

Nov 22 '05 #2
The + appears only if the node has children. In your situation, that
condition is not true. I'd suggest you need to cheat a little, ie add in a
dummy child node that is refreshed when the node is selected. Try this as a
starter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.TreeView1.Nodes.Clear()

Me.TreeView1.Nodes.Add("Root Node 1")

Me.TreeView1.Nodes(0).Nodes.Add("DummyNode")

Me.TreeView1.Nodes.Add("Root Node 2")

Me.TreeView1.Nodes(1).Nodes.Add("DummyNode")

Me.TreeView1.Nodes.Add("Root Node 3")

Me.TreeView1.Nodes(2).Nodes.Add("DummyNode")

End Sub

Private Sub GetCorrectChildNodes()

Dim tnRootNode As TreeNode

tnRootNode = Me.TreeView1.SelectedNode

tnRootNode.Nodes.Clear()

Dim tnNewNode As TreeNode

tnNewNode = New TreeNode("Child Node 1")

tnRootNode.Nodes.Add(tnNewNode)

End Sub

Private Sub TreeView1_BeforeExpand(ByVal sender As Object, ByVal e As
System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand

Me.TreeView1.SelectedNode = e.Node

GetCorrectChildNodes()

End Sub


"Tim Wallace" <twallace-ThisDoesNotBelong-AT-emailDOTcom> wrote in message
news:uC**************@TK2MSFTNGP14.phx.gbl...
I asked this months ago, and never received a reply. Here I go again...

I have a treeview on a Windows Form. I only want to retrieve the top-most
nodes' data from the DB initially. As the user clicks to expand a node, I
will then retrieve its children. Therein lies the problem: I cannot
create a node that displays the plus symbol for the user to click upon.

Can anyone shed some light, please.

Desparate,

Tim

Nov 22 '05 #3

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

Similar topics

4
1285
by: alanrn | last post by:
I am using a TreeView to display the hierarchy of a strongly-typed collection (inherited from CollectionBase). The order of the nodes in the TreeView is strictly tied to the order in which they...
1
6655
by: paradox | last post by:
I want to have a TreeView that shows an image on some items, but not all. Basically, if a certain condition is true, a caution icon is placed next to the treeview item. The problem is that, by...
4
2285
by: pmcguire | last post by:
I have a treeview with a lot of nodes. I want to load only the nodes that are initially visible when the form loads, and then continue to populate it in background and/or when the nodes are required...
7
10406
by: Progalex | last post by:
Hi everybody! I have a listview and a treeview in a form . With an OpenDialog I let the user select multiple files and then these files are added to the listview with the complete pathname,...
0
3106
by: kvrdeveloper1 | last post by:
Hello all, I am populating my treeview with only 1 level of items. Upon opening my screen, I call the RefreshTreeview routine which populates the treeview just fine, and I am able to click on...
2
7479
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...
3
2247
by: Ray Booysen | last post by:
Hi all I have a treeview bound to a sitemap. Once the user is logged in, I'm wanting the menu to expand to include additional items from a database while retaining the items in the sitemap. Is...
10
34416
by: John Rogers | last post by:
This code only counts the parent nodes or rootnodes in a treeview, how do you count all the nodes in a treeview? // one way int NodeCounter = 0; foreach (TreeNode currentNode in...
0
3274
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. ...
3
5439
by: uday1302 | last post by:
Hi All, I have tried by seeing an example. See the below code. Here I have a Problem. Treeview has already one root node and twochild nodes with it. They have to be dragged and dropped in listview....
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
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,...
0
7348
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...
1
7006
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
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1519
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 ...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.