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

 原来做了个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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值