Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Expand All Nodes in Treeview

371 views
Skip to first unread message

Colin

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to

By pressing the * key when the root node is selected in a treeview, all
sub-nodes will be expanded.

How do I do this programmatically? Preferably in vb, but ny help
appreciated.

David Lowndes

unread,
Sep 15, 2000, 2:44:02 AM9/15/00
to

Colin,

The only easy way I've seen of doing this is to fake the '*' key being
pressed. The hard way is to write a recursive routine to expand each
child node.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Colin

unread,
Sep 15, 2000, 3:00:00 AM9/15/00
to
Yes I've done the recursive routine and it takes far too long - presumably
because the treeview redraws for every expansion

Any more ideas?

"David Lowndes" <dav...@mvps.org> wrote in message
news:k6h3ss86lb27vm33c...@4ax.com...

David Lowndes

unread,
Sep 15, 2000, 3:00:00 AM9/15/00
to

>Yes I've done the recursive routine and it takes far too long - presumably
>because the treeview redraws for every expansion

If you don't want the re-draw, have you tried using WM_SETREDRAW
around your code?

webguy

unread,
Sep 15, 2000, 3:00:00 AM9/15/00
to
I don't know that much about vb(i use c++ and mfc) but i do know you use
functions and use event handlers so check in the keydown or keyup handler to
see if the "*" is being hit if so use a function to recursive expand or look
in vb doc on MSDN for a function that does this in vb(mfc with c++ has a
function call ExpandAl() and it is very quick). Well sorry you have to do
the search but that all the time I have because I still have mfc trouble...

David Lowndes <dav...@mvps.org> wrote in message

news:lhu3ss8odo0rrcenv...@4ax.com...


>
> >Yes I've done the recursive routine and it takes far too long -
presumably
> >because the treeview redraws for every expansion
>
> If you don't want the re-draw, have you tried using WM_SETREDRAW
> around your code?
>

Jens Schacherl

unread,
Sep 18, 2000, 3:00:00 AM9/18/00
to
You can send the TVM_EXPAND message to the control:
SendMessage(hWndTreeCtrl, TVM_EXPAND, (WPARAM)nCode, (LPARAM)hTreeItem);

The possible values for nCode are described in MSDN for
CTreeCtrl::Expand function.

HTH, Jens


Colin schrieb:

bli...@my-deja.com

unread,
Oct 13, 2000, 3:00:00 AM10/13/00
to
to simulate this in code, do:

m_treeCtrl.SendMessage(WM_KEYDOWN, (WPARAM)VK_MULTIPLY, (LPARAM)0);

It simulates the '*' action...only make sure you select the root node
first.

-Jeff

Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages