How do I change the selected index/item of a treeview control?
I tried tv.selectedindex = 5 but it says its read only.
I also tried tv.Nodes[5].IsSelected = true; but that does not work either
thanks in advance
Printable View
How do I change the selected index/item of a treeview control?
I tried tv.selectedindex = 5 but it says its read only.
I also tried tv.Nodes[5].IsSelected = true; but that does not work either
thanks in advance
You go to the help documentation for the TreeView class, go to the member listing topic, look down the list of properties until you come to "SelectedNode" and read the following description:Quote:
Gets or sets the tree node that is currently selected in the tree view control.
that does not work form me:
this code:
do ensure the node is visible, but does not select it.Code:TreeNode tmpNode=GetProvinceNode(iProv);
if (iCit!=0)
tmpNode=GetCityNode(tmpNode,iCit);
tmpNode.EnsureVisible();
tvwHierarchy.SelectedNode=tmpNode;
I also wrote some code to figure out the index of the node (yes, got the right index), but still no luck. The node are visible, but selected? huh uh!
any ideas?
ooops...did not see "ShowSelection" property :blush:
Is that anything like the HideSelection property? ;)Quote:
Originally Posted by StrangerInBeijing