如何更改 Telerik winform Treeview 上的展开/折叠图标?
我正在尝试自定义 Telerik Winform TreeView 控件上的展开/折叠图标。
如果我使用 PropertyBuilder 填充 TreeView 控件,我可以看到 Telerik.WinControls.UI.ExpandCollapseElements,我可以修改它来更改展开/折叠图标。不过我想动态地填充我的树。
我已经检查过修改主题,但在 Visual Style Builder 中的任何地方都没有看到 ExpandCollapseElements,也没有看到任何在对象模型的 RadTreeView 端修改这些图标的方法。
屏幕截图说可以做到,但是我缺少什么?
I'm trying to customise the expand/collapse icon on a Telerik Winform TreeView control.
If I populate a TreeView control with the PropertyBuilder, I can see Telerik.WinControls.UI.ExpandCollapseElements which I can modify to change the expand/collapse icons. However I want to populate my tree dynamically.
I have examined modifying the theme but I don't see ExpandCollapseElements anywhere in Visual Style Builder, nor do I see any way to modify these icons at the RadTreeView end of the object model.
Screenshots say it can be done, but what am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在创建节点时直接设置展开/折叠图标。例如:
或者,如果您想更通用地进行格式化(不需要每次创建节点时都指定图像),您可以像这样处理 NodeFormatting 事件:
注意:我相信 NodeFormatting 事件是相对较新,因此您需要最新版本的 Telerik 才能使用它。如果您在使用此代码时遇到问题,请确保您运行的是最新版本的控件。
You can set the expand/collapse icons directly when you are creating the nodes. For example:
Or if you would like to do the formatting more generically (where you don't need to specify the images every time you create a node), you could handle the NodeFormatting event like this:
Note: I believe the NodeFormatting event is relatively new so you'll need a recent version of Telerik to use it. If you have trouble with this code, make sure you're running the latest version of the controls.
要全局更改展开和折叠图像,请执行以下操作:
To globally change the expand and collapse images then do the following:
我最终将我使用的主题保存为 XML,手动编辑该主题的 XML,重新导入 XML 并将其另存为 .tssp。我很幸运,我想要的图像是另一个主题的一部分。
这种方法可能最适合我的情况,因为我们需要主题支持才能使事情在我们支持的所有平台上看起来都很好。
建议的其他方法看起来不错;我还没有尝试过其中任何一个。
I ended up saving the theme I was using as XML, hand editing the XML for that theme, reimporting the XML and saving it as .tssp. I was fortunate that the image I wanted was part of another theme.
This approach probably works best in my situation because we will need theme support to make things look good in all the platforms we support.
The other approaches suggested look good; I haven't tried any of them.