|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Bizarre behavior in design mode when inheriting from a form with a timer.this is so bizarre. Try it for yourself.
In VS 2005: Create a windows control library with 1 form. The only control on the form is 1 enabled timer whose tick event has MessageBox.Show("hello"); Build this library, and reference it from another windows form application. Now create an inherited form, inheriting from the form you just created. What you will witness is this: While you have the Windows App project open, in design mode, somehow the timer will be ticking and it's tick event will get raised. And you will actually see the message box pop up while you are in design mode!! Can anyone explain why this happens? Should this be expected? or is this a major bug? It should be expected.
-- Show quoteHTH, Kevin Spencer Microsoft MVP ..Net Developer A brute awe as you, a Metallic hag entity, eat us. <Michael.Sua***@gmail.com> wrote in message news:1141337067.719081.227060@i39g2000cwa.googlegroups.com... > this is so bizarre. Try it for yourself. > > In VS 2005: > Create a windows control library with 1 form. The only control on the > form is 1 enabled timer whose tick event has MessageBox.Show("hello"); > > Build this library, and reference it from another windows form > application. Now create an inherited form, inheriting from the form you > just created. > > What you will witness is this: > > While you have the Windows App project open, in design mode, somehow > the timer will be ticking and it's tick event will get raised. And you > will actually see the message box pop up while you are in design mode!! > > Can anyone explain why this happens? > Should this be expected? or is this a major bug? > Is there any way to prevent it?
The timer I created is meant to be running when the application is running, not when its in design mode. <Michael.Sua***@gmail.com> wrote in message
news:1141339006.874970.219640@e56g2000cwe.googlegroups.com... if( !DesignMode )> Is there any way to prevent it? > The timer I created is meant to be running when the application is > running, not when its in design mode. { // start timer } Thanks!
What threw me off is that I wasn't expecting the code from the base form to be executed while in design mode. I assumed code was only meant to be executed at run time. But being as you can control what gets executed at design time by using this.DesignMode, it's a cool feature. One note about using this.DesignMode in is, at least what i was experiencing, that DesignMode will always be false when you are checking it from the constructor. Therefore, I had to check for DesignMode in the Load event of the form. |
|||||||||||||||||||||||