User control life cycle in VS2005 editor

G

Guest

Hi,

Can someone tell me what is the user control life cycle when its dropped in
to a visual studio designer? I mean, I have a new windows application project
created in visual studio 2005 and a new form added. Now I create a new user
control extending it from UserControl. Add few properties in user control and
few events. Now when I drop this user control in form, i want to know what
designer does to display it on the form and what event's would be fired and
which events wouldn't fire .

Reason of asking such question is, I have a user control and when i drop it
on a form, it fires its load event and I was under impression, it would not
fire load event when control is in design mode. It must fire it when its in
RunMode. I do check DesignMode property but it seems like its not giving me
right value. Or do i have to implement any other interface with user control
to make DesignMode property work in right way?

Thanks,

Hiten
 
J

Jared Parsons [MSFT]

Hello Hiten,
Reason of asking such question is, I have a user control and when i
drop it on a form, it fires its load event and I was under impression,
it would not fire load event when control is in design mode. It must
fire it when its in RunMode. I do check DesignMode property but it
seems like its not giving me right value. Or do i have to implement
any other interface with user control to make DesignMode property work
in right way?

The problem is the semantics around the DesignMode property. It seems to
only refer to the component that is being designed (i.e. What is doubled
clicked on to open the designer). Once you drop your control onto the form
it is no longer being designed.

A lot of people have run into this issue and if you hit some search engines
you'll find a variety of sulotions. My personal favorite is to implement
a custom property and add a conditional compilation setting (C#) or application
setting (VB) that I toggle to indicate design mode for the custom property.
 

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