I have a tree view that i'm populating with a lot of heiracheral data. I only
want to populate a node with children if the user expands it. However, that
presents a problem. If I do not populate it with children then the
expand/collapse bitmap does not appear.

So, my question is how do I make the expand/collapse bitmap appear without
actually adding any children nodes? Assume that I know there will be children
nodes to add if the user expands it.

--
-Demetri

Re: TreeView Question by Jeff

Jeff
Fri Mar 02 08:54:34 CST 2007

On 02/03/2007 in message
<29DA968B-788D-4B5D-8D0C-E2BD5E5818FF@microsoft.com> Demetri wrote:

>I have a tree view that i'm populating with a lot of heiracheral data. I
>only
>want to populate a node with children if the user expands it. However, that
>presents a problem. If I do not populate it with children then the
>expand/collapse bitmap does not appear.
>
>So, my question is how do I make the expand/collapse bitmap appear without
>actually adding any children nodes? Assume that I know there will be
>children
>nodes to add if the user expands it.

The '.NET' way is to add a dummy node and delete it in the before expand
event (when, presumably, you populate the node).

You can do it with a call to the API:

private void TVSetIcon(JFTreeNode tNode)
{
// Needed to get the correct Icon Mask and ChildCount
TVITEM TV_ITEM = new TVITEM();
TV_ITEM.hItem = tNode.Handle;
TV_ITEM.mask = tNode.Mask | (int)TVIF.TVIF_CHILDREN;
TV_ITEM.state = tNode.State;
TV_ITEM.stateMask = tNode.StateMask;
TV_ITEM.iImage = tNode.ImageIndex;
TV_ITEM.iSelectedImage = tNode.SelectedImageIndex;

// Set child count
TV_ITEM.cChildren = tNode.ChildCount;

// Set the icon with its mask(s)
JFCommon.SendMessage(this.Handle, TVM_SETITEMW, 0, ref TV_ITEM);
}

But that may be more complex than you need?

--
Jeff Gaines

Re: TreeView Question by Bryan

Bryan
Fri Mar 02 16:03:02 CST 2007

Add a dummy node to the unexpanded nodes that have children. When the
user clicks to expand the parent node, replace the dummy node with the
real child nodes.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com



"Demetri" <Demetri@discussions.microsoft.com> wrote in message
news:29DA968B-788D-4B5D-8D0C-E2BD5E5818FF@microsoft.com:

> I have a tree view that i'm populating with a lot of heiracheral data. I only
> want to populate a node with children if the user expands it. However, that
> presents a problem. If I do not populate it with children then the
> expand/collapse bitmap does not appear.
>
> So, my question is how do I make the expand/collapse bitmap appear without
> actually adding any children nodes? Assume that I know there will be children
> nodes to add if the user expands it.
>
> --
> -Demetri