value. There are many blog, etc. posts on this. Apparently this still has
"George Jordanov Ivanov" <george.ivanov@newsgroups.nospam> wrote in message
news:uMnnFm$OGHA.1040@TK2MSFTNGP12.phx.gbl...
> Hi Jason,
>
> You need to check the user control's DesignMode property - it is set to
> true, if your control is in design-time mode, otherwise - false. Thus, the
> initialize logic in your user control should be executed only if this
> property is false.
>
> Check out MSDN online for this specific property at:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodelcomponentclassdesignmodetopic.asp
>
> Regards,
> George Jordanov Ivanov
>
> <commanderjason@gmail.com> wrote in message
> news:1141063660.249379.246780@z34g2000cwc.googlegroups.com...
>>I have a recurring problem with the forms designer is VS.net 2003.
>>
>> If you want to add a UserControl to your form, vs.net will call that
>> controls initialization code when placing the control in the form. I
>> believe this behavior only causes problems. I could care less if the
>> designer can initialize the control at design time as long as the
>> control works at runtime. I would be perfectly happy if the forms
>> designer just used a place holder for the control for the purpose of
>> placing and defining the visual behavior of the control.
>>
>> The problem is that my controls require a bunch of resources to load,
>> one resource for example is the app.config file. I have many things in
>> the config file that my custom control has to load during the controls
>> initialization block. Internationalization settings, file paths,
>> perhaps db connection strings, the options are endless.
>>
>> But as ive seen in the forms designer many resources such as the config
>> file, perhaps language and image resource files, are not available when
>> the control is loaded in the designer, only at runtime.
>>
>> Therefore im forced to add all these try/catch blocks and generally
>> re-write my controls so the designer doesnt choke on something it
>> shouldn't need to do anyway.
>>
>>
>> Another annoyance of this behavior is that if i have my form is all
>> designed and setup, then i go and add some init code to the usercontrol
>> that uses some runtime resource such as the config file, the designer
>> will remove my control and basically erase the control and i have to
>> re-setup and size any and all controls that the designer deems unworthy
>> of running even though the code can and will execute flawlessly at
>> run-time.
>>
>> Does anyone have any strategies that may prevent the designer from
>> running my control init code, or otherwise deal with this very annoying
>> problem?
>>
>
>