VB.Net/GUI/Form Inheritance — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:44, 26 мая 2010
Form template for use with visual inheritance
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class MainClass
Shared Sub Main()
Dim myform As Form = New FrmInheritance()
Application.Run(myform)
End Sub " Main
End Class
Public Class FrmInheritance
Inherits Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents lblBug As System.Windows.Forms.Label
Friend WithEvents lblCopyright As System.Windows.Forms.Label
Friend WithEvents cmdLearn As System.Windows.Forms.Button
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.lblCopyright = New System.Windows.Forms.Label()
Me.cmdLearn = New System.Windows.Forms.Button()
Me.lblBug = New System.Windows.Forms.Label()
Me.SuspendLayout()
"
"lblCopyright
"
Me.lblCopyright.BackColor = System.Drawing.Color.LightYellow
Me.lblCopyright.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblCopyright.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblCopyright.ForeColor = System.Drawing.Color.MidnightBlue
Me.lblCopyright.Location = New System.Drawing.Point(20, 178)
Me.lblCopyright.Name = "lblCopyright"
Me.lblCopyright.Size = New System.Drawing.Size(318, 29)
Me.lblCopyright.TabIndex = 1
Me.lblCopyright.Text = "Copyright."
"
"cmdLearn
"
Me.cmdLearn.BackColor = System.Drawing.Color.Snow
Me.cmdLearn.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdLearn.ForeColor = System.Drawing.SystemColors.InfoText
Me.cmdLearn.Location = New System.Drawing.Point(20, 99)
Me.cmdLearn.Name = "cmdLearn"
Me.cmdLearn.Size = New System.Drawing.Size(144, 59)
Me.cmdLearn.TabIndex = 2
Me.cmdLearn.Text = "Learn More"
"
"lblBug
"
Me.lblBug.BackColor = System.Drawing.Color.LightYellow
Me.lblBug.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblBug.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblBug.ForeColor = System.Drawing.Color.MidnightBlue
Me.lblBug.Location = New System.Drawing.Point(20, 20)
Me.lblBug.Name = "lblBug"
Me.lblBug.Size = New System.Drawing.Size(318, 59)
Me.lblBug.TabIndex = 0
Me.lblBug.Text = "About"
Me.lblBug.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
"
"FrmInheritance
"
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.BackColor = System.Drawing.SystemColors.ActiveBorder
Me.ClientSize = New System.Drawing.Size(358, 223)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdLearn, Me.lblCopyright, Me.lblBug})
Me.Name = "FrmInheritance"
Me.Text = "Visual Inheritance"
Me.ResumeLayout(False)
End Sub
#End Region
" invoked when user presses Learn More button
Private Sub cmdLearn_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdLearn.Click
MessageBox.Show("www.vbex.ru ", "Learn More", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Sub " cmdLearn_Click
End Class
Frame Inherits from another Frame Inheritance
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class MainClass
Shared Sub Main()
Dim myform As Form = New FrmVisualTest()
Application.Run(myform)
End Sub " Main
End Class
Public Class FrmVisualTest
Inherits FrmInheritance
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents cmdProgram As System.Windows.Forms.Button
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.cmdProgram = New System.Windows.Forms.Button()
Me.SuspendLayout()
"
"cmdProgram
"
Me.cmdProgram.BackColor = System.Drawing.Color.Snow
Me.cmdProgram.Font = New System.Drawing.Font("Microsoft Sans Serif", 13.0!, System.Drawing.FontStyle.Bold)
Me.cmdProgram.ForeColor = System.Drawing.SystemColors.InfoText
Me.cmdProgram.Location = New System.Drawing.Point(176, 99)
Me.cmdProgram.Name = "cmdProgram"
Me.cmdProgram.Size = New System.Drawing.Size(144, 59)
Me.cmdProgram.TabIndex = 3
Me.cmdProgram.Text = "Learn The Program"
"
"FrmVisualTest
"
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.ClientSize = New System.Drawing.Size(358, 223)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdProgram})
Me.Name = "FrmVisualTest"
Me.Text = "Visual Test"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub cmdProgram_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdProgram.Click
MessageBox.Show("Info", _
"Learn the Program", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Sub " cmdProgram_Click
End Class
Public Class FrmInheritance
Inherits Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents lblBug As System.Windows.Forms.Label
Friend WithEvents lblCopyright As System.Windows.Forms.Label
Friend WithEvents cmdLearn As System.Windows.Forms.Button
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.lblCopyright = New System.Windows.Forms.Label()
Me.cmdLearn = New System.Windows.Forms.Button()
Me.lblBug = New System.Windows.Forms.Label()
Me.SuspendLayout()
"
"lblCopyright
"
Me.lblCopyright.BackColor = System.Drawing.Color.LightYellow
Me.lblCopyright.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblCopyright.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblCopyright.ForeColor = System.Drawing.Color.MidnightBlue
Me.lblCopyright.Location = New System.Drawing.Point(20, 178)
Me.lblCopyright.Name = "lblCopyright"
Me.lblCopyright.Size = New System.Drawing.Size(318, 29)
Me.lblCopyright.TabIndex = 1
Me.lblCopyright.Text = "Copyright."
"
"cmdLearn
"
Me.cmdLearn.BackColor = System.Drawing.Color.Snow
Me.cmdLearn.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdLearn.ForeColor = System.Drawing.SystemColors.InfoText
Me.cmdLearn.Location = New System.Drawing.Point(20, 99)
Me.cmdLearn.Name = "cmdLearn"
Me.cmdLearn.Size = New System.Drawing.Size(144, 59)
Me.cmdLearn.TabIndex = 2
Me.cmdLearn.Text = "Learn More"
"
"lblBug
"
Me.lblBug.BackColor = System.Drawing.Color.LightYellow
Me.lblBug.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblBug.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblBug.ForeColor = System.Drawing.Color.MidnightBlue
Me.lblBug.Location = New System.Drawing.Point(20, 20)
Me.lblBug.Name = "lblBug"
Me.lblBug.Size = New System.Drawing.Size(318, 59)
Me.lblBug.TabIndex = 0
Me.lblBug.Text = "About"
Me.lblBug.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
"
"FrmInheritance
"
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.BackColor = System.Drawing.SystemColors.ActiveBorder
Me.ClientSize = New System.Drawing.Size(358, 223)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdLearn, Me.lblCopyright, Me.lblBug})
Me.Name = "FrmInheritance"
Me.Text = "Visual Inheritance"
Me.ResumeLayout(False)
End Sub
#End Region
" invoked when user presses Learn More button
Private Sub cmdLearn_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdLearn.Click
MessageBox.Show("www.vbex.ru ", "Learn More", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Sub " cmdLearn_Click
End Class