|
I have a UserControl subclass, CompanyInfo, with various controls (Labels and Textboxes) on it. When I'm designing this class, I can edit the controls, move them around etc., which is fine.
However, when I build CompanyInfo into a DLL, then add it to the Toolbox and drop it onto a form in the Designer, I can no longer edit and move the various controls that CompanyInfo encapsulates. I have tried setting these controls to public access, but that hasn't helped.
I'm using C# in VS .NET 2003. Is there any way to get these child controls to be editable when my subclass is placed on a form? |
| The_Assimilator Tuesday, January 10, 2006 10:51 AM |
| The_Assimilator wrote: | If you have ANY solution to this problem, I'd be happy to hear it. At the moment it looks like my only options are upgrading to .NET 2.0, and/or upgrading to VS .NET 2005 - neither of which I am particularly ready to do.
|
|
This is (by design) not possible in .net 2.0 as like in 1.1
you rather us a panel if you wan't that sort of functionalry
one sort of a solution would be a controlcollection property on your usercontrol that exposes the collection: controls() . then you can edit the properties (sizr/location) of your controls
example
Public ReadOnly Property HostedComtrols() As ControlCollection
Get
Return Me.Controls
End Get
End Property
good luck
Remco |
| RemcoJVG Tuesday, January 10, 2006 4:20 PM |
No, not out of the box
remco |
| RemcoJVG Tuesday, January 10, 2006 11:41 AM |
If you have ANY solution to this problem, I'd be happy to hear it. At the moment it looks like my only options are upgrading to .NET 2.0, and/or upgrading to VS .NET 2005 - neither of which I am particularly ready to do.
|
| The_Assimilator Tuesday, January 10, 2006 12:19 PM |
The behavior you are looking for is contrary to the concept of user controls. The idea is that you, as the developer of the user control, decide what it needs to look like and how it should behave, and then the consumers of your control can use it in their form without having to worry about the layout of the individual components of the control. Why do you need to be able to edit the child controls after the control has been compiled and placed on a form? |
| CommonGenius.com Tuesday, January 10, 2006 2:54 PM |
| The_Assimilator wrote: | If you have ANY solution to this problem, I'd be happy to hear it. At the moment it looks like my only options are upgrading to .NET 2.0, and/or upgrading to VS .NET 2005 - neither of which I am particularly ready to do.
|
|
This is (by design) not possible in .net 2.0 as like in 1.1
you rather us a panel if you wan't that sort of functionalry
one sort of a solution would be a controlcollection property on your usercontrol that exposes the collection: controls() . then you can edit the properties (sizr/location) of your controls
example
Public ReadOnly Property HostedComtrols() As ControlCollection
Get
Return Me.Controls
End Get
End Property
good luck
Remco |
| RemcoJVG Tuesday, January 10, 2006 4:20 PM |
Remco, thanks for the reply; I'll try your suggestion. As to why I'm subclassing UserControl - I tried subclassing Panel first but it gave me the same results (non-editable child components), so I switched to UserControl hoping that it would work. Unfortunately, it doesn't.
CommonGenius, the control I'm trying to build is for an internal project. The idea is that we have a basic set of Labels and Textboxes, which can be moved around and edited as needed (for example, the Textboxes might have different DataBindings in different contexts; the controls might need to be resized to fit onto a certain screen).
|
| The_Assimilator Wednesday, January 11, 2006 6:38 AM |
| The_Assimilator wrote: | | - I tried subclassing Panel first but it gave me the same results (non-editable child components) |
|
What i meant is just using a panel not inheriting from it
remco |
| RemcoJVG Wednesday, January 11, 2006 9:36 AM |
remco, your sugesstion of exposing the Controls collection as a public property works great! Although it's not as intuitive as I might like, it works well enough for my purposes - so thanks.
|
| The_Assimilator Thursday, January 12, 2006 6:13 AM |
cool |
| RemcoJVG Thursday, January 12, 2006 10:23 AM |
this is possible for VS2005 using the EnableDesignMode method of the ControlDesigner class. I suggest you package your control to just have the Label and the TextBox control and not the whole suite.
|
| joeycalisay Tuesday, November 21, 2006 10:58 AM |