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

.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 1456
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
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.