树视图加减图标变大

发布于 2024-07-07 21:11:57 字数 41 浏览 5 评论 0 原文

如何在 C# .net 的树视图中使加号图标更大,而不禁用视觉样式。

How do i make the plus minus icons bigger in the tree view in C# .net with out making visual styles disable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

So尛奶瓶 2024-07-14 21:11:57

我认为你对此没有任何控制权。 您唯一能做的就是重写 DrawNode 事件并自己绘制节点。

首先,您需要将 DrawMode 更改为 OwnerDrawAll。 看一下相关的msdn页面,它包含令人惊讶的详细信息: http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.drawnode.aspx

I don't think you have any control about it. The only thing you can do is override the DrawNode event and paint the nodes yourself.

First you need to change the DrawMode to OwnerDrawAll. Take a look at the relevant msdn page, it contains surprisingly much detail: http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.drawnode.aspx

温折酒 2024-07-14 21:11:57

这有点晚了......但刚刚遇到了这个,并发现(偶然)有一种(间接)方法来控制TreeView(在WinForms中)上加/减号的大小。

您基本上必须添加一个图像列表,并且 TreeView 的加号/减号将随着图像的大小而变化。 要在设计器中看到这一点,请执行以下操作:

  1. 在表单上创建一个 TreeView,并为其添加一些虚拟节点(确保有子节点)
  2. 创建一个图像列表并将其提供给树视图(将其设置到 ImageList 中)属性)
  3. 将图像列表的 ImageSize 设置为 16,16,将树视图的缩进设置为 3 + 图像大小 (19),将树视图的 ItemHeight 设置为图像列表的大小 (16)。
  4. 进入 ImageList 并将 ImageSize 属性更改为 24、24,然后按照步骤 3 中的方式更改 Indent 和 ItemHeight 属性(分别更改为 27 和 24)。 您现在应该在树视图中看到更大的加号/减号。

我不认为列表中必须有图像,尽管我还没有尝试过这种方式。 希望这对某人有帮助。

This is a bit late... but just ran into this, and discovered (by accident) that there is an (indirect) way to control the size of the plus/minus signs on the TreeView (in WinForms).

You basically have to add an image list, and the TreeView plus/minus signs will change with the size of the images. To see this in the designer, do the following:

  1. Create a TreeView on a form, and and some dummy nodes to it (making sure to have children nodes)
  2. Create an image list and give it to the tree view (set it into the ImageList property)
  3. Set the ImageSize of the image list to 16,16 and the Indent of the tree view to 3 + the size of the image (19), and the ItemHeight of the tree view to the size of the image list (16).
  4. Go into the ImageList and change the ImageSize property to 24, 24, and change the Indent and ItemHeight properties as in step 3 (to 27 and 24 respectively). You should now have bigger Plus/Minus signs in the tree view.

I do not believe that you have to have images in the list, though I have not tried it that way. Hope this helps someone.

删除→记忆 2024-07-14 21:11:57

比默认的 10px 左右大吗? 我认为遵循上面的答案,但因为我在尝试确定如何恢复原始大小时遇到​​了这个:

事实证明,如果设置缩进属性,您可以进行一些控制 - 任何小于 10 px 的内容都会开始缩小 +/- 图标。 我有一个树视图,其缩进量设置为 5,我发现将其恢复到 15(甚至 10)可以恢复图标大小。

我希望这可以帮助其他人在该领域寻找解决方案。

Bigger than the default 10px or so? I think follow the answer above, but because I came across this while trying to determine how to restore the original size:

Turns out you have some control if you set the indent property - anything less than 10 px starts to shrink the +/- icons. I had a treeview that was being set with an indent of 5, and I found that by restoring it to 15 (or even 10) restored the icon size.

I hope that helps someone else looking for a solution in that area.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文