Problems with Designer code

  • Thread starter Thread starter LightWarrior
  • Start date Start date
L

LightWarrior

Hello,

I created a form (form1) with an tabcontrol on it. This tabcontrol is
'protected'.
Now I create a new form (form2) and Inherit from form1. Now I can
modify the tabcontrol because of it is protected.

But now I get some problems. When I add some tabpages to the control
and then compile the program I got the error "Child is not a child of
control".

This is because in de Designer code of form2 the 'add-code' disappears
when I compile it. But the SetChildIndex-code is still there. So he
could not set the indexes of the pages because the pages are not childs
of the tabcontrol.

Now I add this code mannualy to the Designer:
"tabcontrol.tabpages.AddRange( ...)". When I compile it now, it will
work. But if I change something on form2 design-time. The error just
comes back.

Does anyone know what the problem could be?

GrtZ
Martijn S.
 
Hi,

Maybe the best is to redesign your class. You cannot add manually any code
to the InitializeComponent beacuse the designer clears and regenerates this
method.
 
Back
Top