• MFC TreeCtrl


    添加子节点

     1 switch(nCurDate)
     2     {
     3     case 1:
     4         m_showDetails.DeleteAllItems( );
     5         hRoot = m_showDetails.InsertItem( "A区", TVI_ROOT);
     6         hfirstChild = m_showDetails.InsertItem("宿舍楼",hRoot);
     7 
     8         hsecondChild = m_showDetails.InsertItem("1楼",hfirstChild);
     9         hsecondChild = m_showDetails.InsertItem("2楼",hfirstChild);
    10         hsecondChild = m_showDetails.InsertItem("3楼",hfirstChild);
    11 
    12         hfirstChild = m_showDetails.InsertItem("教学楼",hRoot,hfirstChild);
    13 
    14         hsecondChild = m_showDetails.InsertItem("阶梯教室",hfirstChild);
    15         hsecondChild = m_showDetails.InsertItem("实验室",hfirstChild);
    16         ShowAllNode(hRoot,m_showDetails);
    17         break;
    18     case 2:
    19         m_showDetails.DeleteAllItems( );
    20         hRoot = m_showDetails.InsertItem( "B区", TVI_ROOT);
    21         hfirstChild = m_showDetails.InsertItem("科技楼",hRoot);
    22 
    23         hsecondChild = m_showDetails.InsertItem("1楼",hfirstChild);
    24         hsecondChild = m_showDetails.InsertItem("2楼",hfirstChild);
    25         hsecondChild = m_showDetails.InsertItem("3楼",hfirstChild);
    26 
    27         hfirstChild = m_showDetails.InsertItem("信息楼",hRoot,hfirstChild);
    28 
    29         hsecondChild = m_showDetails.InsertItem("1号机房",hfirstChild);
    30         hsecondChild = m_showDetails.InsertItem("2号机房",hfirstChild);
    31         hsecondChild = m_showDetails.InsertItem("3号机房",hfirstChild);
    32 
    33         ShowAllNode(hRoot,m_showDetails);
    34         break;
    35     }

    递归展示所有节点

     1 void CdemoDlg::ShowAllNode(HTREEITEM hItem, CTreeCtrl& m_treeShow)
     2 {
     3     HTREEITEM hChild = m_treeShow.GetChildItem(hItem); 
     4     while(hChild)
     5     {
     6         m_treeShow.Expand(hItem,TVE_EXPAND); 
     7         ShowAllNode(hChild,m_treeShow); 
     8         hChild = m_treeShow.GetNextSiblingItem(hChild);
     9     }
    10 }
  • 相关阅读:
    [Oracle整理]synonym及其应用
    [Oracle整理]Oracle之Procedure参数类型
    [Oracle整理]Oracle之数组
    RDL之矩陣
    [Oracle整理]数据类型大全
    [Oracle整理]Oracle之ROWTYPE和RECORD
    [Oracle整理]Oracle游标(显示游标&隐式游标&动态游标&参数游标)
    报表rdl嵌入网页(ASP.NET)
    Linux物理机忘记root密码
    python ftplib下载文件封装
  • 原文地址:https://www.cnblogs.com/Jawen/p/11136742.html
Copyright © 2020-2023  润新知