Welcome Guest Search | Active Topics | Sign In | Register

TreeView Set SelectedNode ServerSide Options
Robert Maxey
Posted: Friday, June 6, 2008 12:10:24 PM
Rank: Newbie
Groups: Member

Joined: 7/18/2007
Posts: 5
Is there a way to set the TreeView's SelectedNode on postback?
eo_support
Posted: Friday, June 6, 2008 1:14:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

Yes. You would just set the node's Selected property directly. For example:

Code: C#
TreeView1.Nodes[0].ChildNode[2].Selected = true;


The reason that it is set on the TreeNode level instead of TreeView level is because TreeView can have multiple selected node.

Setting a node as selected does not automatically display the node. In order to display the node (expand all parent nodes and also scroll the node into view), you must call EnsureVisible method.

Code: C#
TreeView1.Nodes[0].ChildNode[2].EnsureVisible();


Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.