非MDI的表單(Search_Personal)
1.要呼叫MDI的子表單(MGMT_Personal)的副程式
.DisplayDataRow(staffarr, DirectCast(f, MGMT_Personal).FetchDataRow(staffarr))
.SetBindingControlStatus()
並且經由非MDI的表單(Search_Personal)的事件DGV1_SelectionChanged
會即時更改MDI的子表單(MGMT_Personl)的DataGridView1內容!!
2.非MDI的表單(Search_Personal)取MDI的子表單(MGMT_Personal)的值也可以
關係(Relationship):
父表單(MdiParent)MAIN_ligoHRsys下的子表單(MdiChidren)MGMT_Personal
Search_Personal (Not MDI)不屬於MDI...
流程(Step):
MGMT_Personal 開啟 Search_Personal
Search_Personal 呼叫 MGMT_Personal 的副程式
Public Class MGMT_Personal
Dim frm As Search_Personal
Private Sub ToolStripButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton9.Click
'未產生frm物件 才可New Search_Personal 否則會N個 New Search_Personal
If frm Is Nothing OrElse frm.IsDisposed Then frm = New Search_Personal
frm.Show()
frm.Focus()
End Sub
End Class
Public Class Search_Personal
Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
If DataGridView1.CurrentRow IsNot Nothing Then
Dim paraName(0) As String
Dim paraValue(0) As String
paraName(0) = "staff_sn"
paraValue(0) = Trim(DataGridView1.CurrentRow.Cells(6).Value.ToString)
Dim staffDB As New Class_db
Dim staffarr(14) As String
staffarr = staffDB.reReader("select * from [employee] where staff_sn = @staff_sn", paraName, paraValue)
If staffarr(0) Is Nothing Then
Exit Sub
End If
staffDB.Dispose()
'找出父表單MAIN_ligoHRsys下的子表單MGMT_Personal
Dim aryf As Form() = MAIN_ligoHRsys.FindForm().MdiChildren
For Each f As Form In aryf
If f.Name = "MGMT_Personal" Then
'呼叫父表單MAIN_ligoHRsys下的子表單MGMT_Personal的副程式並傳入參數
DirectCast(f, MGMT_Personal).DisplayDataRow(staffarr, DirectCast(f, MGMT_Personal).FetchDataRow(staffarr))
DirectCast(f, MGMT_Personal).SetBindingControlStatus()
Exit For
End If
Next
End If
End Sub
End Class
沒有留言:
張貼留言