在树控件(MFC)中选择节点

时间:2012-07-13 06:50:14

标签: visual-c++ mfc treecontrol

我在VC ++中创建了一个树控件,但是我无法选择子节点。有什么建议吗?

m_pTree->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP |
                 TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT |
                 TVS_SINGLEEXPAND | TVS_SHOWSELALWAYS | 
         TVS_TRACKSELECT,CRect(10, 10, 200, 240), this, 0x1221);

hTree=m_pTree->InsertItem(_T("SoftWare Production") , TVI_ROOT);
hCompany=m_pTree->InsertItem(_T("Microsoft"),hTree);
m_pTree->InsertItem(_T("Office") , hCompany);
m_pTree->InsertItem(_T("Visual Studio") , hCompany);
m_pTree->InsertItem(_T("Servers") ,hCompany , TVI_LAST);

m_pTree->Expand(hCompany, TVE_EXPAND);

hCompany=m_pTree->InsertItem(_T("Linux"),hTree);
m_pTree->InsertItem(_T("Open Office") , hCompany);
m_pTree->InsertItem(_T("QMail") , hCompany);
m_pTree->InsertItem(_T("Apache") ,hCompany,TVI_LAST);



m_pTree->Expand(hCompany, TVE_EXPAND);

1 个答案:

答案 0 :(得分:0)

我认为m_pTree-> SelectItem(HTREEITEM)应该可以工作