spebola Posted March 10, 2003 Posted March 10, 2003 I have a form with a treeview and a listview side by side. When the user selects a row in the listview, I want to expand the corresponding node in the treeview. I have tried the following code but it returns an exception (out of range): Dim tvwIndex as Integer = lvw.FocusedItem.Index tvw.Nodes(tvwIndex).Expand() This code is in the Click event for the listview. Any help would be appreciated. Quote
*Gurus* divil Posted March 10, 2003 *Gurus* Posted March 10, 2003 You can't assume the index will be the same. Indexes start at 0 for each group of nodes under a parent. One way of doing this would be to assign a corresponding treenode to the Tag property of a ListViewItem, then casting it when required: DirectCast(lvw.FocusedItem.Tag, TreeNode).Expand() Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
spebola Posted March 14, 2003 Author Posted March 14, 2003 I finally got back to this project and tried your suggestion and it worked perfectly. Thanks divil!!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.