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开发者_JAVA技巧 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)
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.
精彩评论