如何在listview中加载文件与图像索引 [英] how load file in listview with image index

查看:71
本文介绍了如何在listview中加载文件与图像索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计。这是我的加载方法:

hey guys.this is my load method :

FileStream fsRead = File.Open(openFileDialog1.FileName, FileMode.Open, FileAccess.ReadWrite);
BinaryFormatter binfmt = new BinaryFormatter();
ArrayList deserialized_array_list = (ArrayList)binfmt.Deserialize(fsRead);
Array listviewitem_array = (deserialized_array_list).ToArray(typeof(ListViewItem));
listView1.Items.AddRange((ListViewItem[])listviewitem_array);
fsRead.Close();



此方法适用于加载项目,但如何设置imageIndex以在imageList中加载带有图像的项目?


this method work for loading items, but how can set imageIndex to load items with image in imageList?

推荐答案

ImageList [ ^ ]:您可以按加载图像的顺序控制图像索引。我不认为你可以明确地设置索引。
ImageList[^]: you control image index by the order of the loading images. I don't think you can set the index explicitely.


FileStream fsRead = File.Open(openFileDialog1.FileName, FileMode.Open, FileAccess.ReadWrite);
BinaryFormatter binfmt = new BinaryFormatter();
addresses = (ArrayList)binfmt.Deserialize(fsRead);


   foreach (DictionaryEntry de in addresses) 
        {
            //eject adress
           // Console.WriteLine("{0} lives at {1}.", de.Key, de.Value);
          // contrl index
          listView1.Items.AddRange(de.Value);
        }


这篇关于如何在listview中加载文件与图像索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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