您的位置:首页 > 其它

tree控件----展开树item的函数----CTreeCtrl::Expand

2011-09-20 16:09 405 查看
原来做了个tree控件,用来管理一系列item,可是每次添加item后,需要手动点击“+”号,才能打开树根,看到添加后的结果。就希望在添加一项后,树控件可以自动展开,用到了Expand函数:

m_ctrlTree.Expand(hRoot,TVE_EXPAND);

//hRoot指定要展开的树根(或子根),参数TVE_EXPAND用来执行展开树hRoot中的所有项。

哈哈!一句话搞定!现在与大家分享一下。

下面把CTreeCtrl::Expand 函数各参数的功能说明如下:

BOOL Expand( HTREEITEM hItem, UINT
nCode );

返回值

Nonzero if successful; otherwise 0.

如果成功则返回非零值;否则返回0。

参数说明

hItem

Handle of the tree item being expanded.

要被扩展的tree项的句柄。可以为树根,那么整棵树都被展开。

nCode

A flag indicating the type of action to be taken. This flag can have one of the following values:

用来指示要被进行的动作的标志。这个标志可以是下列值之一:

TVE_COLLAPSE Collapses the list.收缩列表。

TVE_COLLAPSERESET Collapses the list and removes the child items.收缩列表并删除子项。

TVE_EXPAND Expands the list.展开列表。

TVE_TOGGLE Collapses the list if it is currently expanded or expands it if it is currently collapsed.如果列表当前是展开的则收缩列表;反之则展开列表。

备注

Call this function to expand or collapse the list of child items, if any, associated with the given parent item.此成员函数用来展开或收缩给定父项的子项列表(如果有)。

(原文地址:http://www.feiesoft.com/vc/_mfc_ctreectrl.3a3a.expand.htm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: