Expand TreeView not actually expanding 
Author Message
 Expand TreeView not actually expanding

Hi all

I am having a bit of trouble calling the Expand function of the TreeView. If
the Node is not expanded, I want to expand it. It steps through all of the
Expand code but at the end the TreeView's Expanded state is still false and
if I look at it when in Break mode on the 'sKey = ...' line I can't see the
child nodes.

Then when I try to set the SelectedItem it tries to expand the TreeView
again which is causing problems :(

Is there something that I am doing wrong?? It's probably something small
that I'm missing (as always!)

I am calling this code from the DblClick event in a ListView.
----------------------------------------------------------------------------
--------------
If TreeView.SelectedItem.Expanded = False Then
  Call TreeView_Expand(TreeView.SelectedItem)
End If
sKey = GetNodeKey(TreeView.SelectedItem, ListView.SelectedItem.Text)
Set TreeView.SelectedItem = TreeView.Nodes(sKey)
Call TreeView_NodeClick(TreeView.SelectedItem)
----------------------------------------------------------------------------
---------------

Any help is appreciated,

Regards,

Steve.



Mon, 31 Jan 2005 21:35:05 GMT  
 Expand TreeView not actually expanding
Rather than calling the Expand event itself you should be doing:

TreeView.SelectedItem.Expanded = True

--
Ben Baird
Visual Basic Thunder
http://www.vbthunder.com


Quote:
> Hi all

> I am having a bit of trouble calling the Expand function of the TreeView.
If
> the Node is not expanded, I want to expand it. It steps through all of the
> Expand code but at the end the TreeView's Expanded state is still false
and
> if I look at it when in Break mode on the 'sKey = ...' line I can't see
the
> child nodes.

> Then when I try to set the SelectedItem it tries to expand the TreeView
> again which is causing problems :(

> Is there something that I am doing wrong?? It's probably something small
> that I'm missing (as always!)

> I am calling this code from the DblClick event in a ListView.
> --------------------------------------------------------------------------
--
> --------------
> If TreeView.SelectedItem.Expanded = False Then
>   Call TreeView_Expand(TreeView.SelectedItem)
> End If
> sKey = GetNodeKey(TreeView.SelectedItem, ListView.SelectedItem.Text)
> Set TreeView.SelectedItem = TreeView.Nodes(sKey)
> Call TreeView_NodeClick(TreeView.SelectedItem)
> --------------------------------------------------------------------------
--
> ---------------

> Any help is appreciated,

> Regards,

> Steve.



Mon, 31 Jan 2005 21:45:11 GMT  
 Expand TreeView not actually expanding
Hi Ben

I knew there'd be a better way (always is when I do stuff!!)

Thanks for your response, works a treat.

Regards,

Steve.


Quote:
> Rather than calling the Expand event itself you should be doing:

> TreeView.SelectedItem.Expanded = True

> --
> Ben Baird
> Visual Basic Thunder
> http://www.vbthunder.com



> > Hi all

> > I am having a bit of trouble calling the Expand function of the
TreeView.
> If
> > the Node is not expanded, I want to expand it. It steps through all of
the
> > Expand code but at the end the TreeView's Expanded state is still false
> and
> > if I look at it when in Break mode on the 'sKey = ...' line I can't see
> the
> > child nodes.

> > Then when I try to set the SelectedItem it tries to expand the TreeView
> > again which is causing problems :(

> > Is there something that I am doing wrong?? It's probably something small
> > that I'm missing (as always!)

> > I am calling this code from the DblClick event in a ListView.

> --------------------------------------------------------------------------
> --
> > --------------
> > If TreeView.SelectedItem.Expanded = False Then
> >   Call TreeView_Expand(TreeView.SelectedItem)
> > End If
> > sKey = GetNodeKey(TreeView.SelectedItem, ListView.SelectedItem.Text)
> > Set TreeView.SelectedItem = TreeView.Nodes(sKey)
> > Call TreeView_NodeClick(TreeView.SelectedItem)

> --------------------------------------------------------------------------
> --
> > ---------------

> > Any help is appreciated,

> > Regards,

> > Steve.



Mon, 31 Jan 2005 21:52:47 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. TreeView not expanding by DblClick on a node

2. Determine if Treeview is expanded or collapsed

3. Treeview: How can I expand in code

4. TreeView Parent/Child Expanded Question

5. Add Children to Treeview on Expand

6. How to Disable Expand on Treeview control?

7. How can I use the Expand event with my TreeViews

8. Can you prevent TreeView to be collapsed/expanded???

9. TreeView DblClk no expand

10. Expanding Treeview to show selected node

11. treeview expand events

12. Treeview - populate control in the Expand event?

 

 
Powered by phpBB® Forum Software