Icon size in listview

  • Thread starter Thread starter lior_kovarsky
  • Start date Start date
L

lior_kovarsky

Hi,

When the user drags an icon in the listview, i want to prevent him
from dropping
the icon such that it overlapps with another icon. Therefore i need to
know the size
of the icons. Is there a way to know the size?

Thanks,

Lior
 
Hi,

When the user drags an icon in the listview, i want to prevent him
from dropping
the icon such that it overlapps with another icon. Therefore i need to
know the size
of the icons. Is there a way to know the size?

Thanks,

Lior

Hi Lior,

The Icon size is determined by the ImageList used for the current
ListView.View

Size size = Size.Empty;
if(listView1.View == View.LargeIcon)
size = listView1.LargeImageList.ImageSize;

If you hold a reference the the ListViewItem you can also use

Size size = listViewItem.ImageList.ImageSize

Now, if the ListView is ownerdrawn, then you need to keep track of the icon
size somewhere, like the ListViewItem.Tag property
 
Back
Top