下面这段代码有没有问题?为什么图标没有根据条件更换?盼高手指点....
ListView listView1 = new ListView();
listView1.Bounds = new Rectangle(new Point(10, 10), new Size(300, 200));
listView1.View = View.LargeIcon;
listView1.AllowColumnReorder = true;
listView1.Alignment = ListViewAlignment.Default;
listView1.Sorting = SortOrder.Ascending;
for (int i = 100; i < 105; i++)
{
ListViewItem item = new ListViewItem(Convert.ToString(i), 0);
listView1.Items.AddRange(new ListViewItem[] { item });
ImageList imageListLarge = new ImageList();
if (i<102)
{
imageListLarge.Images.Add(Bitmap.FromFile(@"F:\Test\Resources\a.ICO"));
}
else
{
imageListLarge.Images.Add(Bitmap.FromFile(@"F:\Test\Resources\b.ico"));
}
listView1.LargeImageList = imageListLarge;
}
this.Controls.Add(listView1);
------解决方案--------------------------------------------------------
ListViewItem item = new ListViewItem(Convert.ToString(i), 0);
括号中的0就是你的ImageList的索引
而且你的ImageList要绑定到ListView
listview1.LargeImage=你的ImageList这是大图标