Icon size in listview

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
 
M

Morten Wennevik [C# MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top