我有一个的TreeView
Windows窗体控件与的ImageList
,我想一些显示图像的节点的,但其他人没有图像。
I have a TreeView
windows forms control with an ImageList
, and I want some of the nodes to display images, but the others to not have images.
我的不的希望有一个空格所在的形象应该是。我的没有的希望看起来像树视图将借鉴如果没有一个ImageList线的图像。我如何得到它绘制图像的一些项目,而不是别人,而不诉诸笨拙黑客这样?
I don't want a blank space where the image should be. I don't want an image that looks like the lines that the TreeView would draw if it didn't have an ImageList. How do I get it to draw images for some items and not others, without resorting to clumsy hacks like that?
我想这一次,我不认为这是可能的。
I tried this once and I don't think it is possible.
如果您尝试设置两个 ImageKey
和的ImageIndex
来未设置值的控制只是默认值的ImageIndex
0以下code:
If you try to set both ImageKey
and ImageIndex
to "not set" values the control just defaults ImageIndex
to 0. The following code:
treeView.ImageKey = "Value";
Debug.WriteLine(treeView.ImageIndex);
treeView.ImageKey = null;
Debug.WriteLine(treeView.ImageIndex);
treeView.ImageIndex = -1;
Debug.WriteLine(treeView.ImageIndex);
生成输出:
-1
0
0
这样的告诉你,控制开发商要确保总有一个默认的图像。这只是给你留下了黑客的选择,我很害怕。
This kind of tells you that the control developers wanted to make sure that there was always a default image. That just leaves you with the hack options I'm afraid.