现在节点1下有节点2、3,我想给节点2和3设置不同的图标该怎么操作啊?
如果单纯的在开始关联图标的话,那是按树的层次来显示图标的,2和3的图标会是一样的

解决方案 »

  1.   

    不是在添加项目的时候可以给予不同的Imagelist索引吗?
      

  2.   

    [align=left] m_ImageList.Create(16,16,ILC_MASK,4,1);
    m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
    m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
    m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
    m_Tree.SetImageList(&m_ImageList,LVSIL_NORMAL);
    m_Root = m_Tree.InsertItem("学校",0,0);
    m_Child1 = m_Tree.InsertItem("一年级",1,1,m_Root);
    m_Child2 = m_Tree.InsertItem("龙马",2,2,m_Child1);[/align]我是这么写的,那么第一个图片是节点m_Root的,第二个是m_child1的,第三个是m_child2的.
    我现在想的是m_Root不要有图片,m_child1有,m_child2也不要有
      

  3.   


    我没说清楚,初始化的时候已经加了上面的图标了的,现在我想把m_child1的图标改成其他的
      

  4.   

    HTREEITEM InsertItem(
       LPCTSTR lpszItem,
       int nImage,
       int nSelectedImage,
       HTREEITEM hParent = TVI_ROOT,
       HTREEITEM hInsertAfter = TVI_LAST
    );nImage 
    Index of the item's image in the tree view control's image list.
    nSelectedImage 
    Index of the item's selected image in the tree view control's image list.
    把这两个参数设置成不一样的图像索引就好了!!