I want to insert a image in the ImageList at the specified index or you can say that replace the existing image at the perticular index but the Add method can'nt able to resolve this issue ,
imageList.Images.Add("w",Image.FromFile("C:\\Folder.jpg"));
Or,
imageList.Images[listView1.SelectedItems[0].Index]. ????
what can i do????
Loading
Adeel AnsariPosted Sep 17, 2009, 1:15 AM
ImageList img = new ImageList();
imageList.Images.Add("w",Image.FromFile("C:\\Folder.jpg"));
imageList.Images.Add("w",Image.FromFile("C:\\Folder.jpg"));
imageList.Images.Add("w",Image.FromFile("C:\\Folder.jpg"));
imageList.ImageSize = new System.Drawing.Size(30, 40);
listView1.LargeImageList = imageList;
//listView1.LargeImageList.ImageSize = new Size(50,50);
ListViewItem item1 = new ListViewItem("My Computer");
item1.ImageIndex = 0;
ListViewItem item2 = new ListViewItem("My Document");
item2.ImageIndex = 2;
ListViewItem item3 = new ListViewItem("Recycle bin");
item3.ImageIndex = 1;
// Add the items to the ListView.
listView1.Items.AddRange(new ListViewItem[] { item1, item2, item3 });
//listView1.Location = new System.Drawing.Point(6, 15);
//listView1.Name = "lstDPView";
//listView1.Size = new System.Drawing.Size(500, 500);
listView1.ShowItemToolTips = true;
listView1.TabIndex = 0;
//listView1.View = new Size(400, 200);
// listView1.UseCompatibleStateImageBehavior = true;
// listView1.View = View.Tile;
listView1.LabelEdit = true;
Now after that i have attached context menu with the listview,at context menu i have a menuitem name "SHARING" in after clicking that menuitem my perticular listview item images changes not all the items image changes,i think now you can understand my problem,if you have any question please ask me,i have to solve this problem urgently
:-(
Roei BarPosted Sep 16, 2009, 7:44 AM
from the code you wrote it seems like you have a ListView and ImageList
in General you need todo :
Image _image = _ImageList.Images[listView1.SelectedItems[0].Index];
Now set the New Image in the selected Location
_ImageList.Images[listView1.SelectedItems[0].Index] =
_ImageList.Images.Add(