Why does my Windows Form project not use visual styles in XP even when I call Application.EnableVisualStyles?

Published 28 April 04 09:15 PM

     If you set a property on a Windows Forms control which forces the creation of the control (e.g. the SelectedIndex property on the ComboBox class), the control (and perhaps the rest of the form) will not render with visual styles enabled.

     The resolution is to place the code that sets these properties in an event handler for the Load event on the form/control.

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Julian Gall said on April 29, 2004 12:07 AM:
I came across EnableVisualStyles a few days ago but using it caused an SEHException. There are some references on the web that you need to call DoEvents straight afterwards, but opinions differ as to whether this works 100%. See, for example, http://weblogs.asp.net/jkey/archive/2003/07/16/10157.aspx.

Is there an answer to this because usign a manifest file (the alternative) is rather messy.
# Ellis said on April 29, 2004 6:27 AM:
there are many controls which do not support EnableVisualStyles properly. i round the best thing to do is use a manifest file as in .net 1.0.
# Omar Shahine said on April 29, 2004 12:28 PM:
Question, not sure if related.

I have a progress form with a progress bar. I open this form when my program launches. However, if I call Show() in a timer (I currently wait 1 sec before launching the form so that it can appear centered over the parent) the progress bar is not drawing using theming. However if I open the form in the main form's Load method then it draws using theming. However, I can't load it in the form's main method because the center parent property doesn't work since the parent form does not exist in the screen yet.

Is there a way to fix this?
# JFo said on April 30, 2004 8:28 AM:
Raghavendra has got some great tips on how to work with visual styles in Windows Forms at http://blogs.msdn.com/rprabhu/category/2838.aspx
# Reviews said on June 27, 2004 11:36 AM:
http://www.favourite-links.com
http://www.links4you.biz
# RebelGeekz said on December 28, 2004 4:54 AM:
[http://itpeixun.51.net/][http://aissl.51.net/][http://kukuxz003.freewebpage.org/][http://kukuxz001.51.net/][http://kukuxz003.51.net/][http://kukuxz005.51.net/][http://kukuxz002.51.net/][http://kukuxz004.freewebpage.org/][http://kukuxz007.51.net/][http://kukuxz001.freewebpage.org/][http://kukuxz006.51.net/][http://kukuxz002.freewebpage.org/][http://kukuxz004.51.net/][http://kukuxz008.51.net/][http://kukuxz009.51.net/][http://kukuxz005.freewebpage.org/][http://kukuxz006.freewebpage.org/][http://kukuxz007.freewebpage.org/][http://kukuxz009.freewebpage.org/]

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

This Blog

Syndication

Page view tracker