T
trac trinh via .NET 247
Hi, I'm building an MDI application which has a main parent form(ParentForm) and some ChildForm.
On ChildForm, I also call another form, and I also want to add itas a child of ParentForm, it's OK with code below
' ON ChildForm
Public Sub New (ParentForm as Form)
InitializeComponent()
Me.MdiParent = ParentForm
End Sub
' User click Edit to Edit data on a row in datagrid
' Call another form
Private Sub Edit_Click(....)
' To detect whether frmEdit was created or not
Dim fc As Form
For Each fc In Me.MdiParent.MdiChildren
If fc Is frmEdit Then
If fc.WindowState = FormWindowState.MinimizedThen
fc.WindowState = FormWindowState.Normal
End If
fc.Show()
fc.Focus()
Return
End If
Next
' If frmEdit is nothing, create an instance
If frmEdit Is Nothing Then
frmEdit = New frmDatagridRow
frmEdit.MdiParent = Me.MdiParent
frmEdit.Show()
frmEdit.Focus()
End If
End Sub
Everything is OK till I click on X button to edit another row,when I click Edit again, nothing happen, form frmEdit not show.I debugged and see that when we click X button, frmEdit does notrelease resources used. I don't really know why Close() doesn'twork. Anybody help, please !
On ChildForm, I also call another form, and I also want to add itas a child of ParentForm, it's OK with code below
' ON ChildForm
Public Sub New (ParentForm as Form)
InitializeComponent()
Me.MdiParent = ParentForm
End Sub
' User click Edit to Edit data on a row in datagrid
' Call another form
Private Sub Edit_Click(....)
' To detect whether frmEdit was created or not
Dim fc As Form
For Each fc In Me.MdiParent.MdiChildren
If fc Is frmEdit Then
If fc.WindowState = FormWindowState.MinimizedThen
fc.WindowState = FormWindowState.Normal
End If
fc.Show()
fc.Focus()
Return
End If
Next
' If frmEdit is nothing, create an instance
If frmEdit Is Nothing Then
frmEdit = New frmDatagridRow
frmEdit.MdiParent = Me.MdiParent
frmEdit.Show()
frmEdit.Focus()
End If
End Sub
Everything is OK till I click on X button to edit another row,when I click Edit again, nothing happen, form frmEdit not show.I debugged and see that when we click X button, frmEdit does notrelease resources used. I don't really know why Close() doesn'twork. Anybody help, please !