Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make parent node visible in treeview 1

Status
Not open for further replies.

shaunhubbs

Technical User
Jun 6, 2005
57
CA
Hi all,

I was wondering if anyone knew how to make the parent node visible after deleting a child node from a treeview. I know how to get the parent information -- whether it be the index, key or actual description, but I can't figure out from there what I should use to display the node.

The steps I used were:
1) User selects an item (node) in the treeview
2) They click a 'Delete' button which then triggers a stored procedure to delete the item from my SQL database
3) I reload the tree
4) This is where I want to reopen to the parent node. -OR- If it is easier just delete the item I just removed from the SQL database from the tree and leave the tree just the way it is eliminating the reload in Step 3.

Thanks in advance for any help.

- Shaun
 
I think you're trying to expand the original parent node. If so, try setting the Expanded property for that particular node since you already know how to get to it.
-Max
 
That's where I am having the slight problem Max...the syntax...

I have a variable called 'DeletedParent'. Should I set it equal to the index, key or description?

From there what is the syntax for getting it to be 'expanded'. Is it axTreeview.Node(DeletedParent).expanded = true or something else?

Thanks again.

- Shaun
 
Set it to the index, and then axTreeview.Node(DeletedParent).expanded = true should work just fine.
-Max
 
Here is what I have:

Code:
    Dim DeletedParent As Integer
    DeletedParent = axTreeView.SelectedItem.Parent.Index
...
     axTreeView.Node(DeletedParent).Expanded = True

And now I am getting:

'Object doesn't support this property or method.
 
I'm not sure why it would do that, so just remove the selected item alltogether after running the stored procedure. It will take less time and won't flash the treeview as it clears, refils and reexpands node.
-Max
 
I definitely had that thought as well. Unfortunately I cannot seem to get the syntax on removing the selected node. Any suggestions?

Thanks again.

- Shaun
 
Thanks Max! I had just got it as well with the index:

axTreeView.Nodes.Remove axTreeView.SelectedItem.Index
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top