Every form has an overloaded constructor, but one without
parameters amongst them. The code for the frmDetail, and
frmClient is as follows:
frmDetail:
Imports System.Windows.Forms
Namespace Forms
Public Class frmDetail
Inherits System.Windows.Forms.Form
Protected _id As Int32
Protected _openMode As Constants.FormOpenMode
Private _detailName As String =
Constants.EmptyString
#Region " Windows Form Designer generated code "
#Region " Constructor"
Public Sub New()
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
End Sub
Public Sub New(ByVal parentMDI As Form)
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
Me.ParentMDI = parentMDI
End Sub
Public Sub New(ByVal detailName As String)
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
Me.DetailName = detailName
End Sub
Public Sub New(ByVal parentMDI As Form, ByVal
detailName As String)
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
Me.ParentMDI = parentMDI
Me.DetailName = detailName
End Sub
#End Region
'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
'Required by the Windows Form Designer
Private components As
System.ComponentModel.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.
Protected Friend WithEvents btnSave As
System.Windows.Forms.Button
Protected Friend WithEvents btnCancel As
System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.btnSave = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'btnSave
'
Me.btnSave.Anchor = CType
((System.Windows.Forms.AnchorStyles.Bottom Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.btnSave.DialogResult =
System.Windows.Forms.DialogResult.Cancel
Me.btnSave.Location = New System.Drawing.Point
(175, 298)
Me.btnSave.Name = "btnSave"
Me.btnSave.Size = New System.Drawing.Size(70,
25)
Me.btnSave.TabIndex = 19
Me.btnSave.Text = "&Save"
'
'btnCancel
'
Me.btnCancel.Anchor = CType
((System.Windows.Forms.AnchorStyles.Bottom Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.btnCancel.DialogResult =
System.Windows.Forms.DialogResult.Cancel
Me.btnCancel.Location = New
System.Drawing.Point(284, 298)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size
(70, 25)
Me.btnCancel.TabIndex = 17
Me.btnCancel.Text = "&Cancel"
'
'frmDetail
'
Me.AutoScaleBaseSize = New System.Drawing.Size
(5, 13)
Me.ClientSize = New System.Drawing.Size(367,
332)
Me.Controls.Add(Me.btnSave)
Me.Controls.Add(Me.btnCancel)
Me.MinimumSize = New System.Drawing.Size(375,
370)
Me.Name = "frmDetail"
Me.ResumeLayout(False)
End Sub
#End Region
#Region " Public Properties"
Public Property Id() As Int32
Get
Return _id
End Get
Set(ByVal Value As Int32)
If Not _id.Equals(Value) Then
_id = Value
sbSetFormText()
If Not Value.Equals(0) Then
sbSetRecord()
End If
End If
End Set
End Property
Public Property DetailName() As String
Get
Return _detailName
End Get
Set(ByVal Value As String)
_detailName = Value
End Set
End Property
Public WriteOnly Property ParentMDI() As Form
Set(ByVal Value As Form)
Me.MdiParent = Value
End Set
End Property
Public WriteOnly Property OpenMode() As
Constants.FormOpenMode
Set(ByVal Value As Constants.FormOpenMode)
_openMode = Value
sbSetFormText()
sbSetControlsMode()
End Set
End Property
#End Region
#Region " Private routines"
Protected Overridable Sub sbSetControlsMode()
End Sub
Protected Overridable Sub sbSetRecord()
End Sub
Protected Overridable Function fnCheck() As
Boolean
End Function
Protected Overridable Sub sbSetFormText()
Select Case _openMode
Case Constants.FormOpenMode.newRecord
Me.Text = "Create New " & _detailName
Case Constants.FormOpenMode.editRecord
Me.Text = "Modify " & _detailName
& " " & _id.ToString
Case Constants.FormOpenMode.viewRecord
Me.Text = "View " & _detailName & " "
& _id.ToString
End Select
End Sub
#End Region
Private Sub frm_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
General.SetFormPosition(Me)
End Sub
Private Sub frm_Closing(ByVal sender As Object,
ByVal e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
General.SaveFormPosition(Me)
Me.Dispose()
End Sub
Private Sub btnCancel_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnCancel.Click
Me.Close()
End Sub
End Class
End Namespace
And frmClient:
Friend Class frmClient
Inherits BaseClasses.Forms.frmDetail
#Region " Windows Form Designer generated code "
#Region " Constructor"
Public Sub New()
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
End Sub
Public Sub New(ByVal openMode As
Constants.FormOpenMode)
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
Me.OpenMode = openMode
End Sub
Public Sub New(ByVal parentMDI As Form)
MyBase.New(parentMDI)
'This call is required by the Windows Form
Designer.
InitializeComponent()
End Sub
Public Sub New(ByVal parentMDI As Form, ByVal
openMode As Constants.FormOpenMode)
MyBase.New(parentMDI)
'This call is required by the Windows Form
Designer.
InitializeComponent()
Me.OpenMode = openMode
End Sub
#End Region
'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
'Required by the Windows Form Designer
Private components As System.ComponentModel.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()
components = New System.ComponentModel.Container
Me.Text = "frmClient"
End Sub
#End Region
#Region " Overrides"
Protected Overrides Sub btnSave_Click(ByVal sender As
Object, ByVal e As System.EventArgs)
End Sub
#End Region
Protected Overrides Function fnCheck() As Boolean
End Function
Protected Overrides Sub sbSetControlsMode()
End Sub
Protected Overrides Sub sbSetRecord()
End Sub
End Class
There isn't much code in those as I cannot add controls
to it...
-----Original Message-----