| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 20924 | 2002-06-14 05:51:00 | Treeview in VB | Guest (0) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 54362 | 2002-06-14 05:51:00 | Im wondering what is wrong with the following code. Dim GoToNode As String Options.Show DoEvents: DoEvents Set GoToNode = 'Registration' Set Options.OptionsTree.SelectedItem = GoToNode 'Options is a form 'OptionsTree is a Treeview 'Registration is a node in the tree And the error I get is 'Object Required' on the last GoToNode |
Guest (0) | ||
| 54363 | 2002-06-17 01:39:00 | The reason why this doesn?t work is because the SelectedItem property of a TreeVew object expects a node object, not just a text string like ?Registration?. The reason for this is that there's more to a node than just some text (have a look at the Node object in the VB help). All you need to do is add a node object with your ?Registration? text to the TreeView and you should be away laughing e.g.: Dim GoToNodeLabel As String Options.Show DoEvents: DoEvents With Options.OptionsTree .Nodes.Add , , 'Registration', 'Registration' .Nodes.Add 'Registration', tvwChild, 'Child1', 'Child1' .Nodes.Add 'Registration', tvwChild, 'Child2', 'Child2' Set .SelectedItem = .Nodes('Registration') End With Double click the root ?Registration? node and you?ll see the child nodes. |
Guest (0) | ||
| 54364 | 2002-06-17 01:40:00 | The reason why this doesn?t work is because the SelectedItem property of a TreeVew object expects a node object, not just a text string like ?Registration?. The reason for this is that there's more to a node than just some text (have a look at the Node object in the VB help). All you need to do is add a node object with your ?Registration? text to the TreeView and you should be away laughing e.g.: Dim GoToNodeLabel As String Options.Show DoEvents: DoEvents With Options.OptionsTree .Nodes.Add , , 'Registration', 'Registration' .Nodes.Add 'Registration', tvwChild, 'Child1', 'Child1' .Nodes.Add 'Registration', tvwChild, 'Child2', 'Child2' Set .SelectedItem = .Nodes('Registration') End With Double click the root ?Registration? node and you?ll see the child nodes. |
Guest (0) | ||
| 54365 | 2002-06-17 01:44:00 | The reason why this doesn?t work is because the SelectedItem property of a TreeVew object expects a node object, not just a text string like ?Registration?. The reason for this is that there's more to a node than just some text (have a look at the Node object in the VB help). All you need to do is add a node object with your ?Registration? text to the TreeView and you should be away laughing e.g.: Dim GoToNodeLabel As String Options.Show DoEvents: DoEvents With Options.OptionsTree .Nodes.Add , , 'Registration', 'Registration' .Nodes.Add 'Registration', tvwChild, 'Child1', 'Child1' .Nodes.Add 'Registration', tvwChild, 'Child2', 'Child2' Set .SelectedItem = .Nodes('Registration') End With Double click the root ?Registration? node and you?ll see the child nodes. |
Guest (0) | ||
| 1 | |||||