TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
learner learner
NA
29
155.4k
Replace imagelist item with a new image
Jan 29 2012 5:26 AM
I have filled an imagelist using the following code in a button click. everything works fine.
DirectoryInfo dir = new DirectoryInfo(@"c:\MyPic");
foreach (FileInfo file in dir.GetFiles())
{
imageList1.Images.Add(Image.FromFile(file.FullName));
}
listView1.View = View.LargeIcon;
imageList1.ImageSize = new Size(100, 100);
listView1.LargeImageList = this.imageList1;
ListViewItem item;
for (int i = 0; i < this.imageList1.Images.Count; i++)
{
item = new ListViewItem();
item.ImageIndex = i;
item.Text = "Image " + i.ToString();
listView1.Items.Add(item);
}
But when i replace any image in the imagelist and refresh the list box then the full image is not displayed, a portion of the image is displayed. Codes are as follows:
// here I replace the image at a specific place
imageList1.Images[listView1.FocusedItem.ImageIndex] = img;
listView1.Refresh();
I think I have to change the imagelayout as stretch. But how could i do that? and why the full image is displayed at first time?
Reply
Answers (
0
)
Implementation of association and dependency in csharp
Override private virtual methods in C#