D
DBC User
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());
}
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());
}