0
votes

I have created a base form to use as a template. It inherits System.Windows.Forms.Form. I added one Label control to test, and it automatically generated the following code:

Friend WithEvents Label1 As System.Windows.Forms.Label

Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.AutoSize = True
    Me.Label1.Location = New System.Drawing.Point(12, 9)
    Me.Label1.Name = "Label1"
    Me.Label1.Size = New System.Drawing.Size(39, 13)
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Label1"
    '
    'FormPanel
    '
    Me.ClientSize = New System.Drawing.Size(284, 262)
    Me.Controls.Add(Me.Label1)
    Me.Name = "FormPanel"
    Me.ResumeLayout(False)
    Me.PerformLayout()

End Sub

I want to create some forms that inherit this base form. In the solution explorer, I add a new item, select the "Inherited Form" type. Then I choose my base form.

It creates the form just fine, but controls inside it don't show up at all in the designer. I've tried rebuilding the project between every step, no go.

Any idea why they aren't showing up?

2
How are you making the template? Once you've designed the form you want to use as a template, go to the File menu and choose Export Template. Once the wizard is done you can load the form as a new item, controls and property values all the same. I've used this method to make several templates both forms and projects, and the controls always show up. - tinstaafl

2 Answers

0
votes

I tried what you describe, and I'm not seeing the same issue. My inherited form shows the label control of the base form. I'm sure I'm doing something slightly differently - I inserted a new "Inherited Form", based it off of the base form, made zero changes, and yet the label control showed up, so it must be somehow related to the base form. The only thing that jumps out at me in your post is that my auto-generated code for the base form includes settings for AutoScaleDimensions, AutoScaleMode, ClientSize, and Text properties. Also, I'm using Visual Studio 2013.

Can you post more details of your base form?

0
votes

Figured it out myself! I actually had to lock the controls in the template form. For anyone searching who may find this.. just set the "Locked" property to true on the controls inside the form.