C
Chien Lau
I frequently define internal UserControl-derived classes in my WinForms
apps:
internal class MyUserControl:UserControl{
...
}
I'll often need to embed these controls in a Form, whose class is
contained in the same assembly as the control. As far as I know, the only
way to do this using the designer is to add the UserControl-derived object
to the toolbox and then drag it from the toolbox to the target form.
To accomplish this, I use the toolbox's Add/Remove Items functionality.
When adding new UserControl(s) to the toolbox, the user is asked to choose
an assembly containing the UserControl. I browse for and choose the assembly
that I'm currently working on, call it /debug/MyAssembly.dll. The problem is
that the toolbox is only prepared to accept UserControl items that are
declared as "public," not those declared as "internal." For a variety of
reasons, I'd much prefer to have UserControls declared as internal if I'm
not exposing them to the outside world.
The only workaround is to temporarily change the scope of the
UserControl to public, recompile, Add the item to the toolbox, change the
modifier back to internal, and recompile again. I then have access to the
control from my toolbox. This clearly an ugly workaround. Do you know of an
easier way to add internal controls to the toolbox?
Thanks...
apps:
internal class MyUserControl:UserControl{
...
}
I'll often need to embed these controls in a Form, whose class is
contained in the same assembly as the control. As far as I know, the only
way to do this using the designer is to add the UserControl-derived object
to the toolbox and then drag it from the toolbox to the target form.
To accomplish this, I use the toolbox's Add/Remove Items functionality.
When adding new UserControl(s) to the toolbox, the user is asked to choose
an assembly containing the UserControl. I browse for and choose the assembly
that I'm currently working on, call it /debug/MyAssembly.dll. The problem is
that the toolbox is only prepared to accept UserControl items that are
declared as "public," not those declared as "internal." For a variety of
reasons, I'd much prefer to have UserControls declared as internal if I'm
not exposing them to the outside world.
The only workaround is to temporarily change the scope of the
UserControl to public, recompile, Add the item to the toolbox, change the
modifier back to internal, and recompile again. I then have access to the
control from my toolbox. This clearly an ugly workaround. Do you know of an
easier way to add internal controls to the toolbox?
Thanks...