CTreeCtrl

简介: CTreeCtrl

1.初始化图片列表 CTreeCtrl

CImageList m_imglstTreeFolder;
 m_imglstTreeFolder.Create( 16 , 16 , ILC_COLOR24 | ILC_MASK , 1 , 0  ) ;
 m_imglstTreeFolder.Add(AfxGetApp()->LoadIcon( IDR_MAINFRAME ));
 m_imglstTreeFolder.Add(AfxGetApp()->LoadIcon( IDI_INBOX ));
 m_imglstTreeFolder.Add(AfxGetApp()->LoadIcon( IDI_OUTBOX ));
 m_imglstTreeFolder.Add(AfxGetApp()->LoadIcon( IDI_DRAFTBOX ));
 m_imglstTreeFolder.Add(AfxGetApp()->LoadIcon( IDI_SENT ));
 m_imglstTreeFolder.Add(AfxGetApp()->LoadIcon( IDI_DELETED ));
 m_treeFolder.SetImageList( &m_imglstTreeFolder , LVSIL_NORMAL ) ;
 HTREEITEM hRoot ;
 hRoot = m_treeFolder.InsertItem( "我的邮箱" , 0 , 0 ) ;
 m_treeFolder.InsertItem( "收件箱" , 1 , 1 , hRoot ) ;
 m_treeFolder.InsertItem( "发件箱" , 2 , 2 , hRoot ) ;
 m_treeFolder.InsertItem( "草稿箱" , 3 , 3 , hRoot ) ;
 m_treeFolder.InsertItem( "已发送邮件" , 4 , 4 , hRoot ) ;
 m_treeFolder.InsertItem( "已删除邮件" , 5 , 5 , hRoot ) ;
 m_treeFolder.Expand( hRoot , TVE_EXPAND ) ;
 m_treeFolder.SetTextColor( RGB( 128 , 0 , 128 ) ) ;

1.初始化并展开列表

void CMyClass::InitTree()
{
HTREEITEM m_hItem=m_Tree.InsertItem("联通积分业务管理",TVI_ROOT);
 HTREEITEM hItem1 =m_Tree.InsertItem("数据操作",m_hItem);
 m_Tree.InsertItem("数据导入",hItem1);
 m_Tree.InsertItem("数据导出",hItem1);
 HTREEITEM hItem2 = m_Tree.InsertItem("查询数据",m_hItem);
 m_Tree.InsertItem("业务数据查询",hItem2);
 m_Tree.InsertItem("积分数据查询",hItem2);
 HTREEITEM hItem3 = m_Tree.InsertItem("积分换购",m_hItem);
 m_Tree.InsertItem("换购积分",hItem3);
 m_Tree.InsertItem("换购记录",hItem3);
 HTREEITEM hItem4 = m_Tree.InsertItem("其他",m_hItem);
 m_Tree.InsertItem("查询",hItem4);
 MyExpandTree(m_Tree.GetRootItem());
}
void CMyClass::MyExpandTree(HTREEITEM hTreeItem)
{
 if(!m_Tree.ItemHasChildren(hTreeItem))
 {
  return;
 }
 HTREEITEM hNextItem = m_Tree.GetChildItem(hTreeItem);
 while (hNextItem != NULL)
 {
  MyExpandTree(hNextItem);
  hNextItem = m_Tree.GetNextItem(hNextItem, TVGN_NEXT);
 }
 m_Tree.Expand(hTreeItem,TVE_EXPAND);
}


相关文章
|
BI
17 MFC - 列表控件 CListCtrl
17 MFC - 列表控件 CListCtrl
71 0
|
区块链
18 MFC - 树控件 CTreeCtrl
18 MFC - 树控件 CTreeCtrl
46 0
|
API 索引
MFC 树形控件CTreeCtrl类
MFC 树形控件CTreeCtrl类
398 0
MFC 树形控件CTreeCtrl类
Devexpress treelist 控件属性大全
属性列表 1、OptionsSelection: EnableAppearanceForcusedCell:选中的Cell的Appearance设置是否可用。默认为True; EnableAppearanceForcusedRow:选中的Node的Appearance设置是否可用。
1740 0