wrong TreeView node selected


R

rfm

I have a TreeView with 1 expanded top node, it has several childnodes
(call it row A), which have childs of their own.

The top node is selected correctly and all childnodes from the row A
nodes are selected correctly.

But if I select (with the mouse) one of the nodes in row A it always
displays the first node in row A as selected.

Is this a bug in treeview or something, cause I can't think of any
reason it does this.

--
 
Ad

Advertisements

Ad

Advertisements

R

rfm

Thanx, now I at least know why it doesn't work, apparently value needs
to be unique.
Problem is node.value needs to be the same for some nodes in my app.
So I found another solution.

Treeview_load is called before TreeView1_SelectedNodeChanged and
contains the correct selected node.
example:

public TreeNode selectedNode;

protected void TreeView1_SelectedNodeChanged(object sender,
EventArgs e)
{
if (selectedNode != null)
{
TreeView1.SelectedNode.Selected = false;
selectedNode.Select();
}
....
}

protected void TreeView1_Load(object sender, EventArgs e)
{
if (TreeView1.SelectedNode != null)
{
selectedNode = TreeView1.SelectedNode;
}
}




--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top