Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I have a listview on Windows Form, which has groups and 2 columns. First column should show up image and other one is for the text. The listview is set to View = Tile and ImageList is supplied to LargeImageList property.

Now, when i run the application in Windows XP mode the Image doesn't show up where as when the same application when runned on Windows 7, the image shows up in the list.

Application already has code to EnableVisualStyle, please see below.
C#
if (Application.RenderWithVisualStyles == false)
				{
				    var listView1 = new List<listviewitem>();
                    Application.EnableVisualStyles();

                    // If visual styles did not turn on (we are in Citrix or they are turned 
                    // off in Windows), we don't want DoEvents to post messages
                    if (Application.RenderWithVisualStyles)
                        Application.DoEvents();
                }

When this code is executed in Windows XP, the inside look doesn't execute DoEvent().
Secondly, even if forcefully executed DoEvents(), still the image doesn't show up in Windows XP.

If anybody could shed some light on this and help me resolve it...

Thank You,
Rachna

[Edit]Code block added[/Edit]
Posted
Updated 4-Dec-12 7:11am
v2
Comments
Sergey Alexandrovich Kryukov 4-Dec-12 16:14pm    
What does it mean: "doesn't execute DoEvent()"? (DoEvents, not "DoEvent".)
Why using this method at all?
--SA
Member 3830335 5-Dec-12 8:19am    
RenderWithVisualStyles stays false after enablingvisualstyles in Windows XP, whereas in Windows 7 it is true. I am not sure if DoEvents() is doing something to help perform controls the same as it is shows up in Windows 7
Sergey Alexandrovich Kryukov 8-Jan-13 13:20pm    
I did not see this message because you did not reply to mine, you put it on the same level.
Using DoEvents is wrong, in most cases including this...
—SA

1 solution

After enabling VisualStyle it may take sometime to get True for RenderWithVisualStyles property. Try executing another DoEvents() before checking this property.
 
Share this answer
 
Comments
Member 3830335 5-Dec-12 8:19am    
What do you specifically mean by "executing another DoEvents()"?
Akbar Ali Hussain 5-Dec-12 12:43pm    
Execute Application.DoEvents() after Application.EnableVisualStyles()
Member 3830335 6-Dec-12 9:51am    
I implemented what you mentioned but did not resolve the issue. I am running in a VM which is in Windows XP Mode 32 bit. Would that matter?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900