我正在一個項目中,我有一個家庭窗體,其中有兩個按鈕用於登錄員工和administrator.after點擊按鈕登錄窗體將打開,但我想只要登錄窗口打開d以前的家庭窗體必須關閉或隱藏..也有在家裏的登錄頁面上的鏈接,但只要用戶點擊家庭鏈接家庭窗體的新實例打開,我希望停止dis多次打開form.i試着關閉()和隱藏()但沒有用.... 代碼爲form1 ie home form;如何防止表單的多個實例?
Public Class Form1
Inherits System.Windows.Forms.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
'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.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Georgia", 12.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(136, 184)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(100, 40)
Me.Label1.TabIndex = 8
Me.Label1.Text = "Employee Login"
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("Georgia", 12.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(288, 184)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(136, 48)
Me.Label4.TabIndex = 12
Me.Label4.Text = "Administrator Login"
'
'Button1
'
Me.Button1.BackgroundImage = CType(resources.GetObject("Button1.BackgroundImage"), System.Drawing.Image)
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button1.Location = New System.Drawing.Point(152, 104)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 64)
Me.Button1.TabIndex = 16
'
'Button2
'
Me.Button2.BackColor = System.Drawing.Color.Transparent
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button2.Image = CType(resources.GetObject("Button2.Image"), System.Drawing.Image)
Me.Button2.Location = New System.Drawing.Point(312, 104)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 64)
Me.Button2.TabIndex = 17
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(7, 15)
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(496, 341)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label1)
Me.Font = New System.Drawing.Font("Georgia", 9.75!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form1"
Me.Text = "Employee Management System"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frmDialogue As New Form5
frmDialogue.ShowDialog()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim frmDialogue As New Form7
frmDialogue.ShowDialog()
End Sub
End Class