views:

121

answers:

1

I'm trying to get my head around this behaviour: I have a ListView on a form in LargeIcon View (System.Windows.Forms.View.LargeIcon)

This line is in the constructor:

this.listView1.LargeImageList.ImageSize = new Size(32, 32);

And then this function is called upon a double click:

private void listView1_DoubleClick(object sender, EventArgs e)
{
    this.listView1.LargeImageList.ImageSize = new Size(64, 64); 
}

When I double click on the listview, the size changes as expected, but the icon I have is taken away, and I just get a big blank space. Even if I set the ImageIndex to use afterwards, it stays blank, and I can't seem to get it displaying again.

I assume I'm doing something wrong (although I guess .NET could be broken). What do I change such that the icon does not disappear?

(I am in .NET 2.0)

+2  A: 

I think you are running into this caveat described in MSDN (http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.imagesize.aspx):

Because setting the ImageSize property causes the handle to be recreated, you should set ImageSize prior to setting the Images property.

Besides, relying on the system to resize the images from 32x32 to 64x64 would naturally result in low quality images.

binarycoder
Yeah, I'm not concerned about the low-quality images as I'm just prototyping at the moment. It's more just that the images disappear and I can't get them to display again. It appears that the caveat you describe is indeed the problem - would this then mean that I have to recreate the set of images every time I wish to change the size of the icons?
Smashery