ImageList with ListView and TreeView

I

Ian

Hi, I've been trying to create a listview and treeview with icons. You
would think it's a pretty straight forward task. API documentation
states you simply assign an ImageList - that's been populated either
using VS.NET (my method) or programatically.

I assigned the imagelist to the small icons in the listview.

Even VS.NET has been satisfied with what I'm doing as it shows the
listitems/treenodes with icons. As soon as I build/run however, all
icons are missing.

One thing to note is I had originally extended a standard list, added
the images using the extended class (using the very same listview) and
it worked. Unfortunately, a list isn't powerful enough for my
purposes.

I've spent 10 hours (prob more) trying to fix this. I've installed all
possible patches, examined my code line-by-line. Tried to reproduce
the .net API examples. Nothing.

Has anyone had a similar issue? If so - Please help... please?
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

Sounds really weird, the only thing that comes to my mind is that when you
use WinXP, you should call Application.DoEvents prior to calling
Application.Run(). You can find more on this in the "Applying Windows XP
Visual Styles to Windows Forms Applications" topic in MSDN.

To quote the article:

<quote>
Note If one of the controls on your form is an ImageList control, be sure
to include the following line of code before calling Application.Run().

// C#
Application.DoEvents();
</quote>
 
I

Ian

THANK YOU!

THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!
THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!
THANK YOU! THANK YOU! THANK YOU! ... THANK YOU!

Your suggestion worked!

Of course, it's always something simple like that :| 25 hours on one
little problem and it comes down to 30 odd characters of text!

Once again, thank you. I honestly thought no one would know what the
problem was - let alone care.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Ian,

I am really glad my suggestion has worked! Also keep in mind that, on WinXP,
the format to which ImageLists are serialized when stored in resource files
is *different* to that on Win2K and earlier versions.
 

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