473,396 Members | 1,927 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.

Treeview questions

I am trying to build a tree like the following

Root
|--- Current
|-------- Date1
|-------- Date2
etc.,

First I create the root, then make the root as the selected node and
create Current and add it to the selected node. That is fine. Now I
make the Current as selected node, but, it comes back null. I am using
the following code, does anyone know why would the selected node
comeback null??

Thanks.

treeView3.Nodes.Clear();
treeView3.Nodes.Add(tRoot, tRoot); //tRoot = 'Root' string
treeView3.ExpandAll();
treeView3.SelectedNode = treeView3.Nodes[tRoot];
TreeNode cnode = new TreeNode();
cnode.Text = currentRoot; //currentRoor = 'Current' string
cnode.Name = currentRoot;
treeView3.SelectedNode.Nodes.Add(cnode);

//get treq, it is a database query to fetch all matching
rows
if (tReq.AnyRowAvailableAll())
{
tReq.Rewind();
do
{
treeView3.SelectedNode =
treeView3.Nodes[currentRoot];
if (treeView3.Nodes[tReq.AName] == null)
{
TreeNode node = new TreeNode();
node.Text = tReq.AName;
node.Name = tReq.AName;
treeView3.SelectedNode.Nodes.Add(node);
node = null;
}
} while (tReq.MoveNext());
}

Oct 22 '06 #1
1 1187
You don't need to use the selected node. This should work just as well:

TreeNode ANode;
treeView1.Nodes.Clear();
ANode = treeView1.Nodes.Add("Root");
ANode = ANode.Nodes.Add("Current");
if (tReq.AnyRowAvailableAll())
{
tReq.Rewind();
do
{
ANode.Nodes.Add(tReq.AName, tReq.AName);
} while (tReq.MoveNext());
}

--
Regards, Peter
Oct 22 '06 #2

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

Similar topics

5
by: fgh | last post by:
Hello, two questions please: 1) In a treeview, I want to display folders like it is done in Windows Explorer. Do I have to do this manually or can I set something up in VS.NET 2003? 2) Most...
4
by: IndeX? | last post by:
Hello, I'm parsing from an xml file (using DOM), so that i can place certain nodes in a TreeView. Xml file looks like this: <questions> <question ID="Question 01" Text="Some Text"> <answers>...
2
by: EdB | last post by:
I'll admit, it was late....but I could not find the answer to these two questions. How can determine if the node that a user clicked on: 1) is a parent (top level only)? 2) has children? ...
6
by: amruta | last post by:
Dim objNode As MSComctlLib.Node TreeView1.ImageList = ImageList1 'Assign the image list to TreeView Set objNode = TreeView1.Nodes.Add() 'Create the Server Node I need to conver the above VB 6.0...
0
by: Alan Silver | last post by:
Hello, I have a treeview control that is populated from an XML file. I have two questions... 1) Is it possible to specify where the treeview starts showing nodes? I aks this as there is a...
5
by: Paul | last post by:
Hi, I am a self taught VBA programmer, and I'm trying to learn VB2005 Express (The price was right). I like the look of the treeview control, and I'd like to use it as a menu system for my users,...
3
by: William Sullivan | last post by:
I desperately want to replace my hand-made ajax treeview with the 2.0 TreeView. The webpage I'm designing uses the postbacks to dynamically fill the treeview. The reason why I'm doing this is...
3
by: orit | last post by:
I have the following xml: <?xml version="1.0" ?> <course> <globalProperties> <externalMetadata> <source>ADL</source> <model>ADL SCORM 1.0</model> </externalMetadata> </globalProperties>
2
by: engwar1 | last post by:
I'm a .Net newbie and have started writing a Windows Forms application to assist me in choosing files/directories to move from one drive to another. Basically what I want is something like the...
3
by: bg_ie | last post by:
Hi, Lets say I have a TreeView with nodes that represent objects of a number of different types. Is there a way of associating the Set method of each object with its node in the TreeView? That...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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...

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.