如何将图像添加到Treeview? [英] How do I add Images to Treeview?

查看:87
本文介绍了如何将图像添加到Treeview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想将图像添加到我的树形视图中.我已经看过一些教程,而没有(C#中的大多数示例),我需要使用VB进行一些解释.我已经添加了一个图像列表并选择了要添加到根目录和文件夹/子文件夹中的图片,然后选择取消选择和选择的图标图片来使用.当我单击确定"按钮时,我的树形视图显示了新添加的图标,但是我无法构建程序吗?错误.....我如何获取和设置图像?我需要使用任何代码来指向我正在使用的图标文件,还是需要指向索引号,如何?

有人可以给我一个小例子吗?

Hello once again Im looking to add images to my treeview. I have seen some turtorials and what not (most examples in C#) I need some explaination with VB. I have added a imagelist and selected the pictures I wish to add to the root and folders/subfolders and then choose the unselect and selected icon pics to use also. When I click the ok button my treeview shows the newly added icons but I cannot build the program? it errors..... how do I get and set the images? is there any code that I need to use to point to the icon files im using or do I need to point to the index number some how?

can someone give me a small example of how to do this?

thank you in advance..

推荐答案

我假设您正在谈论System.Windows.Forms,但您应始终指出要使用的库:WPF,ASP.NET ,所以如果我回答错误的问题也不要怪我.读Microsoft文档这么难吗?无论如何,您都必须阅读它.

System.Windows.Forms有两组图像.请参见属性ImageListStateImageList.这些图像列表表示要在每个音符处显示的整套图像或小图像16x16.最好始终将它们全部用于所有节点,或者始终对其中一个节点使用,但不要修改您的选择(当您只显示正常图像,而又一次显示两个图像时,则不允许这种情况).在运行时使用特殊索引选择图像.在此处查看代码示例: http://msdn.microsoft.com/en -us/library/system.windows.forms.treeview.imagelist.aspx [ http://msdn.microsoft.com/zh-cn/library/system.windows.forms.treeview.stateimagelist.aspx [ http://msdn.microsoft .com/en-us/library/system.windows.forms.treeview.aspx [
I assume you''re talking about System.Windows.Forms, but your should always indicate the library you use: WPF, ASP.NET, so don''t blame me if I''m answering a wrong question. Was that so difficult to read Microsoft documentation? You will have to read it anyway, see below.

There are two sets of images for System.Windows.Forms; see properties ImageList, and StateImageList. These image lists represent a whole set or small images 16x16 to be shown at each note. You better always use all of them for all nodes or always one of them, but not modify your choice (don''t allow the situation when you sometime show only normal image, another time both images). The images are selected during run-time using special indexing. See code samples here: http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.imagelist.aspx[^], and here http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.stateimagelist.aspx[^].

See documentation on TreeView class for more detail: http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.aspx[^].

—SA


这篇关于如何将图像添加到Treeview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆