Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2005

Tip: Looking for answers? Try searching our database.

ListView and ImageList problem - disappearing icons between runs.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rik Hemsley - 05 Jan 2005 12:00 GMT
Hi,

I'm using a ListView in Details mode and have assigned an ImageList to
it via its SmallImageList property.

If I make a trivial change to the code of my application, and then run
it, the images show up within the ListViewItems as expected.

The next time, and each subsequent time, that I run my application
(through the VS.NET 2003 debugger or compiled and outside VS.NET), the
images do not appear. It appears that display space is reserved for
them, but they show as blank.

If I make another trivial change (such as clearing a list which has just
been created), the images will be displayed in the next run of the
application.

This behaviour is quite consistent, though on a few occasions I have
managed to run the application twice before the icons start disappearing.

The images are loaded from embedded resources and I have checked with
the debugger that they are always loaded correctly and added to the
ImageList.

I cannot fathom how it is possible for this problem to occur only on the
second and subsequent runs after a compile.

A trivial test application does not have the same problem.

Rik
Herfried K. Wagner [MVP] - 05 Jan 2005 13:23 GMT
"Rik Hemsley" <rik@rikkus.info> schrieb:
> I'm using a ListView in Details mode and have assigned an ImageList to it
> via its SmallImageList property.
>
> If I make a trivial change to the code of my application, and then run it,
> the images show up within the ListViewItems as expected.

Are you using 'Application.EnableVisualStyles' in your application?  If you
do so, call 'Application.DoEvents' immediately after calling
'EnableVisualStyles'.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/

Rik Hemsley - 05 Jan 2005 14:18 GMT
> Are you using 'Application.EnableVisualStyles' in your application?  If you
> do so, call 'Application.DoEvents' immediately after calling
> 'EnableVisualStyles'.

I already do that, but thanks anyway!

Rik
Rik Hemsley - 05 Jan 2005 14:24 GMT
> Are you using 'Application.EnableVisualStyles' in your application?  If you
> do so, call 'Application.DoEvents' immediately after calling
> 'EnableVisualStyles'.

The DoEvents didn't fix it (I already had it) but getting rid of
EnableVisualStyles did.

Now my application looks completely out of place on XP and Server 2003
but at least it's functional!

Thanks for pointing me in the right direction.

Rik
Rik Hemsley - 05 Jan 2005 14:31 GMT
> The DoEvents didn't fix it (I already had it) but getting rid of
> EnableVisualStyles did.

For anyone who's had a similar problem: If you ensure that
EnableVisualStyles is _first_ in your Main(), then that fixes the
problem I had while still allowing the XP styling to work.

I think my problem was that I was showing a splash screen before calling
EnableVisualStyles.

Rik
Herfried K. Wagner [MVP] - 05 Jan 2005 16:31 GMT
"Rik Hemsley" <rik@rikkus.info> schrieb:
> I think my problem was that I was showing a splash screen before calling
> EnableVisualStyles.

Well, that would have been my next suggestion ;-).

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.