Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4346442
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:10:25+00:00 2026-05-21T12:10:25+00:00

Form1 Public Class Form1 Private Sub But_Bell_Click(sender As System.Object, e As System.EventArgs) Handles But_Bell.Click

  • 0

Form1

Public Class Form1

Private Sub But_Bell_Click(sender As System.Object, e As System.EventArgs) Handles But_Bell.Click
    MessageBox.Show("Ding a ling")
End Sub

End Class

First Decendant

Public Class BellsAndWhistles
Inherits Form1
Friend WithEvents But_Whistle As System.Windows.Forms.Button

Private Sub InitializeComponent()
    Me.But_Whistle = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'But_Whistle
    '
    Me.But_Whistle.Location = New System.Drawing.Point(112, 38)
    Me.But_Whistle.Name = "But_Whistle"
    Me.But_Whistle.Size = New System.Drawing.Size(75, 23)
    Me.But_Whistle.TabIndex = 1
    Me.But_Whistle.Text = "Whistle"
    Me.But_Whistle.UseVisualStyleBackColor = True
    '
    'BellsAndWhistles
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.Controls.Add(Me.But_Whistle)
    Me.Name = "BellsAndWhistles"
    Me.Text = "Bells & Whistles"
    Me.Controls.SetChildIndex(Me.But_Whistle, 0)
    Me.ResumeLayout(False)

End Sub

Private Sub But_Whistle_Click(sender As System.Object, e As System.EventArgs) Handles But_Whistle.Click
    MessageBox.Show("Toot Toot")
End Sub

End Class

First Decendent Designer

Second Descendant

Public Class MoreBellsAndWhistles
Inherits BellsAndWhistles
Friend WithEvents MoreBells As System.Windows.Forms.Button

Private Sub InitializeComponent()
    Me.MoreBells = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'MoreBells
    '
    Me.MoreBells.Location = New System.Drawing.Point(30, 145)
    Me.MoreBells.Name = "MoreBells"
    Me.MoreBells.Size = New System.Drawing.Size(75, 23)
    Me.MoreBells.TabIndex = 1
    Me.MoreBells.Text = "More Bells"
    Me.MoreBells.UseVisualStyleBackColor = True
    '
    'MoreBellsAndWhistles
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.Controls.Add(Me.MoreBells)
    Me.Name = "MoreBellsAndWhistles"
    Me.Text = "MoreBellsAndWhistles"
    Me.Controls.SetChildIndex(Me.MoreBells, 0)
    Me.ResumeLayout(False)

End Sub

Private Sub MoreBells_Click(sender As System.Object, e As System.EventArgs) Handles MoreBells.Click
    MessageBox.Show("Ting TIng")
End Sub

Private Sub MoreBellsAndWhistles_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

End Sub

End Class

Second Descendant Designer

Where has the whistle button gone?

The class part of the inheritance has works because you can access it via code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:10:26+00:00Added an answer on May 21, 2026 at 12:10 pm

    Try calling MyBase.InitializeComponent() from the second descendant. You’ll probably have to change the access level of it, too.

    EDIT

    This was bugging me all night. It turns out that its a case of missing constructors. If you use reflector you’ll see that Form1 has a constructor that calls Me.InitializeComponent() even though that doesn’t exist in either Form1.vb or Form1.Designer.vb.

    <DesignerGenerated> _
    Public Class Form1
        Inherits Form
        ' Methods
        Public Sub New()
            Me.InitializeComponent
        End Sub
    
        ...
    End Class
    

    If you create a C# WinForms app the constructor is visible so this makes me think its a VB thing to hide it. Also, if you manually add a Sub New to Form1 it will fill in some code for you, essentially “unhiding it”.

    I’m guessing that VS looked at your code and realized that it was a descendant of System.Windows.Forms.Form but technically it was done improperly since it didn’t call MyBase.New() (since it couldn’t because it didn’t exist) so it was just trying to guess. It “knows” to add a call to InitializeComponent() in the form that it created and it “knows” to do that for the form that you’re looking at but it isn’t bothering to walk the chain of forms and do it for all of them. Bug? Maybe.

    When you set MoreBellsAndWhistles as a startup form you never see either of the new buttons, right? This is how you can tell its more of a VS trickery involved.

    Anyway, the solution to the entire problem is to add this to both sub classes:

    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub
    

    And add this to Form1:

    Public Sub New()
        InitializeComponent()
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

. private void Form1_Load(object sender, EventArgs e) { List<CaclulatedData> tests = new List<CaclulatedData> {
You should be able to create a generic form: public partial class MyGenericForm<T> :
I have a form that has a public property public bool cancelSearch = false;
In handling a form post I have something like public ActionResult Insert() { Order
I have a public property set in my form of type ListE<T> where: public
I have the following enumeration: public enum AuthenticationMethod { FORMS = 1, WINDOWSAUTHENTICATION =
I have the following code: <script type=text/javascript> function SubmitForm() { form1.submit(); } function ShowResponse()
My form receives asynchronous callbacks from another object on random worker threads. I have
I've created a simple solution with 2 projects. The 1st project (class library) contains
I don't know enough about VB.Net yet to use the richer HttpWebRequest class, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.