|
When I drag a control onto my designer from the toolbox, it works great. I can add sub-controls etc. If I save and close the form, then reload it, all the panels/groupboxes etc do not accept controls being dropped onto them anymore, the controls simply drop to the main surface (behind the container control).
In my BasicDesignerLoader, in PerformLoad, I loop through my data and create my controls. I do something like the following:
Protected Overrides Sub PerformLoad(ByVal serializationManager As System.ComponentModel.Design.Serialization.IDesignerSerializationManager)
Dim component As IComponent = LoaderHost.CreateComponent(GetType(RootControl), "Form") Me.SetBaseComponentClassName("Form")
'Load my data Object
Dim tempControl As someDataType For Each tempControl In myDataObject.Controls CreateControl(tempControl, CType(component, Control)) Next
Me.LoaderHost.EndLoad("UserControl", True, errors) End Sub
Private Sub CreateControl(Byval controlObj as someDataType, ByVal parent as Control) 'Figure out the type
Dim newComponent as IComponent = LoaderHost.CreateComponent(myCtrlType, controlObj.name) ctrl = CType(newComponent, Control) ctrl.parent = parent
'Set the user entered properties
Dim tempObj as someDataType For each tempObj in controlObj.Controls CreateControl(tempObj, ctrl) Next End Sub
|