PDA

Click to See Complete Forum and Search --> : How Can You Change The Selected Index Of A Treeview Control


2MuchRiceMakesMeSick
Aug 6th, 2006, 05:58 PM
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

jmcilhinney
Aug 6th, 2006, 06:51 PM
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:Gets or sets the tree node that is currently selected in the tree view control.

StrangerInBeijing
Jan 11th, 2007, 01:35 AM
that does not work form me:
this code:
TreeNode tmpNode=GetProvinceNode(iProv);
if (iCit!=0)
tmpNode=GetCityNode(tmpNode,iCit);
tmpNode.EnsureVisible();
tvwHierarchy.SelectedNode=tmpNode;
do ensure the node is visible, but does not select it.
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?

StrangerInBeijing
Jan 11th, 2007, 01:41 AM
ooops...did not see "ShowSelection" property :blush:

jmcilhinney
Jan 11th, 2007, 02:12 AM
ooops...did not see "ShowSelection" property :blush:Is that anything like the HideSelection property? ;)