【问题标题】:CTreeCtrl setting selected item programmaticallyCTreeCtrl 以编程方式设置所选项目
【发布时间】:2011-05-01 14:56:09
【问题描述】:

我想以编程方式设置要选择的树 ctrl 项的状态,然后在其他地方处理它。我想这样做以重用用户单击它时调用的代码。我尝试了这个,但它失败了,为什么?

// somewhere in the code

m_tree.SetItemState(hItemToBeSelected, TVIS_SELECTED, TVIS_SELECTED);
CommonFunction();

// elsewhere

CommonFunction()
{
HTREEITEM h = m_tree.GetSelectedItem();// this returns NULL.
}

我该怎么做?

【问题讨论】:

    标签: mfc tree


    【解决方案1】:

    您想使用 SelectItem 而不是 SetItemState:http://msdn.microsoft.com/en-us/library/w8hy20sy(v=VS.100).aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多