如何按字符串查找树视图项? [英] How to find tree view item by string ?
问题描述
大家好!
我想首先感谢所有花时间查看此主题并尝试提供帮助的人。
我有一个通过资源编辑器在对话框中创建的树视图控件。
我必须找到一个节点,文本标签是与字符串变量相同并选择它。
一个小例子:
------------ --------------------------
带有节点的树视图控制
+第一个节点
|
| __第二个节点
。
。
。
char [10] test =第二个节点; // char变量
------------------------------ ---------------------------
因为在上面的例子中测试变量和第二个节点有相同的文字,我应该以编程方式选择第二个节点。
这是我的问题,所以我的问题是:
我该怎么做?
我使用纯WIN32 API在MS Visual Studio Express 2008,Windows XP,C ++中工作。
这就是全部,再次感谢所有试图帮助的人。非常感谢你!
Hello everyone!
I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.
I have a tree view control created in dialog via resource editor.
I have to find a node which text label is the same as the string variable and select it.
A small example:
--------------------------------------
TREE VIEW CONTROL WITH NODES
+ First node
|
|__ Second node
.
.
.
char[10] test = "Second node"; // char variable
---------------------------------------------------------
Since in the above example test variable and second node have the same text I should select programmatically the second node.
That is my problem, so my question is:
How do I do that ?
I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.
That would be all, again I thank everyone who tries to help.Thank you very very much!
推荐答案
请参阅CP有关该主题的精彩文章,它看起来很老但看起来还不错:
在Win32 API下使用TreeControl(TreeView) [ ^ ]
希望它有所帮助!
干杯,
江户
See CP's nice article on the subject, it's an oldie but it looks ok:
Using TreeControl (TreeView) under Win32 API[^]
Hope it helps!
Cheers,
Edo
没有神奇药丸,我不得不遍历通过节点并比较字符串,找到匹配的节点。
幸运的是,树视图的节点数和子节点数很少。
至于匹配节点的选择,我刚刚使用了TreeView_SelectItem(...)宏。
[enhzflep编辑]:解决方案:查找树视图节点label等于字符串变量 [ ^ ]
There is no " magic pill ", I had to traverse through the nodes and compare the strings, to find a matching node.
Luckily, the treeview's number of nodes and child nodes is small.
As for selection of a matching node, I have just used TreeView_SelectItem( ... ) macro.
[enhzflep EDIT]: Solution here: find treeview node by which label equals string variable[^]
这篇关于如何按字符串查找树视图项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!