By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

Application.EnableVisualStyles() breaks my program!

P: n/a
I added Application.EnableVisualStyles() as the first statement in Main() of
my program, and didn't notice much change in visual appearance, but what I
*did* notice is that some of my buttons stopped working! They were enabled
but no longer called their OnClick methods.

I tried adding Application.DoEvents() right after EnableVisualStyles and
that didn't help.

What gives? In VS 2005/.NET 2.0, is EnableVisualStyles broken? This is
under Windows XP.
Jun 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Works fine from everything I have seen... Does it fix itself if you
remove this line again?

I suspect that what has happened is that at some point you have gone
into the form designer, and it has decided to drop your events from the
init step; this always happens if you cut / paste a control around on
the form, but the designer is also notorious for doing freaky things at
the most inoportune times.

Just check the current (form) class against an old (working) version -
see what changed; I suspect a missing "this.{control}.{event} += {blah
handler};".

And if you think events are brittle in the designer, don't go *near*
data-binding in the designer ;-p

Marc

Jun 21 '06 #2

P: n/a
Michael A. Covington wrote:
I added Application.EnableVisualStyles() as the first statement in Main()
of my program, and didn't notice much change in visual appearance, but
what I
*did* notice is that some of my buttons stopped working! They were
enabled but no longer called their OnClick methods.

I tried adding Application.DoEvents() right after EnableVisualStyles and
that didn't help.

What gives? In VS 2005/.NET 2.0, is EnableVisualStyles broken? This is
under Windows XP.


Hi Michael,

Without more information, I'm unable to reproduce your bug. However, a
couple of things to look for is the FlatStyle property of your buttons. It
needs to be set to System in order for them to render in the System's
visual style. Are you using the Windows Forms Designer? Do the visual
styles show up there while you are designing your form?

Thanks,
-- Tom Spink
Jun 21 '06 #3

P: n/a
"Tom Spink" <ts****@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Michael A. Covington wrote:
I added Application.EnableVisualStyles() as the first statement in Main()
of my program, and didn't notice much change in visual appearance, but
what I
*did* notice is that some of my buttons stopped working! They were
enabled but no longer called their OnClick methods.


Hi Michael,

Without more information, I'm unable to reproduce your bug. However, a
couple of things to look for is the FlatStyle property of your buttons.
It
needs to be set to System in order for them to render in the System's
visual style. Are you using the Windows Forms Designer? Do the visual
styles show up there while you are designing your form?

Thanks,
-- Tom Spink


Thanks for responding. I'm going to check out the FlatStyle property, and
in fact any other property that might distinguish the afflicted buttons from
other ones. Also, the way I create my initial form is rather complicated
(several forms pop up at once when the program starts) and I'm going to
experiment with cutting out all the complexity (even if I lose part of the
program) to see if I can get the problem to go away.

What is really bizarre is that one of the buttons works OK until I put data
into a DataGridView that is on the same form, and then it stops working
properly.
Jun 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.