views:

124

answers:

1

Hi I've setup a few subforms all inheriting from a root form that sets up a few buttons and logos etc to then filter down to the children. I used the visual studio wizard to add the subforms inheriting from the root and they are automatically declared with:

    public partial class WelcomeForm : MynetInstaller.rootForm

I've now been asked to resize the subforms and move a button, things I hope would be done by simply changing the root form and allowing the changes to filter down.

The two problems I have are: 1/ I change the size, this does not affect the children at all, it seems after the initial setup the size is not inherited.

2/ I change the location of a button, this causes all subforms to break showing an error that:

To prevent possible data loss before loading the designer, the following errors must be     resolved:   



'child' is not a child control of this parent.     

Instances of this error (1)  

1.   Hide Call Stack 

at System.Windows.Forms.Control.ControlCollection.GetChildIndex(Control child, Boolean     throwException)
at System.Windows.Forms.Control.ControlCollection.SetChildIndexInternal(Control child, Int32 newIndex)
at System.Windows.Forms.Control.ControlCollection.SetChildIndex(Control child, Int32 newIndex)
at   System.Windows.Forms.Design.ControlDesigner.DesignerControlCollection.SetChildIndex(Control child, Int32 newIndex)  

If i press continue it will load the page, but wont have moved the button and if i try and run it i get an error in:

this.Controls.SetChildIndex(this.btnNext, 0);

Saying:

'child' is not a child control

I noticed that when i move the control it stops becoming locked, but changing this manually doesn't help.

A: 

The base form's Size is inherited, the designer normally prevents setting the size again in the derived form. But mishaps can happen, a sub form might have been subtly altered once. Or it might have been designed on a machine that had a different video DPI setting from the machine on which the base form was designed.

There is only workaround for this that I can think of, edit the designer-generated code. In the Solution Explorer window, open the node next to the sub-form and double-click the Designer.cs file. Expand the region labeled "Windows Form Designer generated code" and locate the assignment to the ClientSize property. Delete it.

No idea what's going on in your second problem, this is not a normal issue. Take a look at what happens to the designer generated code when you manipulate the button.

Hans Passant