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
최종 클래스
먼저 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
최종 클래스
둘째 후손
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
최종 클래스
는 어디 호각 버튼을 간?상속의 클래스 부분은 코드를 통해 액세스 할 수 있기 때문에 효과가 있습니다.
:
Form1
이를을 그리고 추가
어쨌든, 전체 문제에 대한 솔루션은 하위 클래스에이를 추가하는 것입니다 첫 번째 하강자도 그것을 요구합니까? –
@ Adam Speight, 업데이트 된 게시물을 참조하십시오.그것은 기본적으로 VS 추측입니다. –
문제를 해결해 주셔서 감사합니다. VS Designer에서 대신 vb.net의 기본 Form 인스턴스를 선택하여 "true"이유가 발생했는지 궁금합니다. –