'ฟอร์ม Main
Public _Permis as Integer = 0
Private Sub showFrom(frmName As Form, Optional NewPermis = 0)
For Each f In Me.MdiChildren
Then f.Close()
Next
_Permis = NewPermis
frmName.MdiParent = Me
frmName.WindowState = FormWindowState.Maximized
frmName.Show()
End Sub
'--------------------------------------------------------------------------------------------------
'ฟอร์มปลายทางเมื่อ Load
Private Sub FrmMatImport_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Permission(_Permis)
End Sub
'--------------------------------------------------------------------------------------------------
'คลาส Module
Public Function Permission(permis As Integer)
Select Case permis
Case 0
FrmTest.GroupInput.Visible = True
Return True
Case 1
FrmTest.GroupInput.Visible = False
Return True
End Select
Return False
End Function
ถ้าอยากให้มันจำค่าเก่าก็ไม่ต้องปิดฟอร์ม แค่สั่ง Show ก็พอ
Code (VB.NET)
Private Sub showFrom(frmName As Form, Optional NewPermis = 0)
Dim frm As Form = frmName
For Each f In Me.MdiChildren
frm = f
Next
_Permis = NewPermis
frm.MdiParent = Me
frm.WindowState = FormWindowState.Maximized
frm.Show()
End Sub
'ฟอร์ม Main
Public _Permis as Integer = 0
Private Sub showFrom(frmName As Form, Optional NewPermis = 0)
For Each f In Me.MdiChildren
Then f.Close()
Next
_Permis = NewPermis
frmName.MdiParent = Me
frmName.WindowState = FormWindowState.Maximized
frmName.Show()
End Sub