Listview Icon Shuffle

P

Paul Kay

Listview Icon Shuffle - Has anyone else experienced this?

Using VB.Net CF I have a Listview displaying large icons which I have added
to the control and the imagelist dynamically, pre-sorted by name.

I have used SendMessage and LVM_SETICONSPACING to set the pitch of the icons
(Thank you Alex Feinman)

All of that works as hoped (expected?)

When I display a second form using showdialog and then return to the
original form with the Icon display, I have to reassign the imagelist to the
listview (this is, I understand, a know 'bug' with the CF Listview).

I then have to re-set the icon pitch (From my testing it appears that
several different listview actions cause it to lose a previously set icon
spacing - these include reassigning the imagelist, beginupdate, endupdate
and clear.... But that's another matter, for now I can work around those
'bugs')

However, the crux of my problem is that the icons are no-longer displayed in
the original sorted order, but have undergone a subtle shuffle, although
they still link correctly to the underlying files which they represent.

Questions:

Is this a genuine Bug with the listview, as a result of changing the icon
spacing (I don't experience it when using the default spacing)?

Is it me?

I hope my explanation above is sufficient for someone to gain an insight to
my problem, as there would be an awful lot of code to extract and post a
working/failing example.

TIA
Paul Kay
 
A

Alex Feinman [MVP]

Paul Kay said:
Listview Icon Shuffle - Has anyone else experienced this?

Using VB.Net CF I have a Listview displaying large icons which I have added
to the control and the imagelist dynamically, pre-sorted by name.

I have used SendMessage and LVM_SETICONSPACING to set the pitch of the icons
(Thank you Alex Feinman)

You are welcome.
All of that works as hoped (expected?)

When I display a second form using showdialog and then return to the
original form with the Icon display, I have to reassign the imagelist to the
listview (this is, I understand, a know 'bug' with the CF Listview).

In one of my applications I have a "main menu" built as a ListView with
custom spacing. This spacing does not seem to be affected by launching a
modal dialog, not the imagelist has to be reassigned. Was there some
mentioning of this issue before, to which you refer?
I then have to re-set the icon pitch (From my testing it appears that
several different listview actions cause it to lose a previously set icon
spacing - these include reassigning the imagelist, beginupdate, endupdate
and clear.... But that's another matter, for now I can work around those
'bugs')

However, the crux of my problem is that the icons are no-longer displayed in
the original sorted order, but have undergone a subtle shuffle, although
they still link correctly to the underlying files which they represent.

Questions:

Is this a genuine Bug with the listview, as a result of changing the icon
spacing (I don't experience it when using the default spacing)?

If everytihing else fails, you can try setting item positions explicitly by
sending LVM_SETITEMPOSITION. Not pretty, but will probably work. Since you
know the icon size, spacing and the client area size, constructing two
nexted loops should be trivial.
 
P

Paul Kay

In one of my applications I have a "main menu" built as a ListView with
custom spacing. This spacing does not seem to be affected by launching a
modal dialog, not the imagelist has to be reassigned. Was there some
mentioning of this issue before, to which you refer?

Alex,

The imagelist 'issue', is caused by having other imagelists in the
application with different image sizes. In my case, these occur in several
modal dialogs which may be called after the first listview and imagelist
have been populated and displayed.

An admission of the 'issue' and a solution, which solved the problem I was
having at that time, was explained in this thread:

http://groups.google.com/[email protected]&rnum=9

and possibly a couple of others.

Hopefully, we'll get a better listview in the next release, meanwhile I'll
try your suggestion.

Regards
Paul Kay
 

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