带有格式化文本的 c# Treeview 节点,例如选项卡和标签 新线路
是否可以(通过使用库存 c# TreeView)拥有多行 TreeNode?
另外,是否可以向 TreeNode 的文本添加控制字符,例如“\t”? 通过向 TreeNode 添加列也可以实现相同的效果。 这可能吗?
Is it possible (by using the stock c# TreeView) to have Multiline TreeNodes?
Also, is it possible to add control characters to TreeNode's text e.g. '\t'? This same effect could also be achieved by adding columns to the TreeNode. is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不相信使用 WinForms 可以做到这一点,至少在不绘制自己的节点的情况下是这样。 您也许可以使用“所有者绘制”树节点在 WinForms 中完成此操作,但我不知道。
不过,WPF 本身就支持这一点。
I do not believe this is possible using WinForms, at least without drawing your own nodes. You may be able to use an "owner-drawn" treenode to accomplish this in WinForms, though, I don't know.
This is natively supported with WPF, though.
从您的问题中并不清楚您是使用 ASP.NET 还是 WinForms。 如果您使用 ASP.NET,您可以尝试使用 PRE 标记来获取格式...?
这就是 Ra-Ajax TreeView 的意思,您可以在此处查看 的示例 可以包含任意数量的 HTML 和/或什至其中的控件,这在很大程度上使其优于 ASP.NET 中内置的 TreeView。 (免责声明;我使用 Ra-Ajax)
这使您可以完全按照您的意愿格式化 TreeView 的内容。 不过,如果你完全发疯,你仍然面临着由于空间太大或类似的原因而创建“显示伪影”的风险......
It isn't very clear from your question whether you are on ASP.NET or WinForms. If you're in ASP.NET you could try using the PRE tag to get formatting...?
What that's said the Ra-Ajax TreeView which you can see an example of here can have any arbitrage amount of HTML and/or even controls within it which mostly makes it way superior to the built in TreeView in ASP.NET. (Disclaimer; I Work with Ra-Ajax)
This makes it possible for you to format the contents of the TreeView exactly as you wish. Though if you go completely berserk you still run the risk of creating "display artifacts" due to too much space or something like that...
在 TreeNode 中不可能有效地使用制表符。
无论如何,我有一个解决方法:
字体“Consolas”每个字母的间距相等,因此您可以轻松地用空格分隔。 GetEmptyInfoByIndex 方法返回一个自定义长度的空格字符串来填充间隙,直到达到指定的长度。 这里 = 20。
证明在这里!
It is not possible to use the tabulator effectively inside a TreeNode.
Anyways, I have a workaround:
The Font "Consolas" has equal space of each letter so you can space easily with blanks. The method GetEmptyInfoByIndex returns a custom lenght string of spaces to fill the gap until a specified length. Here = 20.
Proof here!