Results 1 to 11 of 11

Thread: [RESOLVED] What is the best way to close all open child forms

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2017
    Posts
    11

    Resolved [RESOLVED] What is the best way to close all open child forms

    Hello, I need some help.

    How (what is the best way) to close all open child forms in VB.NET?

    Here is my code and screenshot of the program.

    Name:  Screenshot_1.jpg
Views: 7201
Size:  28.8 KB

    vb.net Code:
    1. Public Sub ShowForm(ByVal Frm As Form)
    2.         For Each frmClose As Form In MainForm.MdiChildren
    3.             frmClose.Close()
    4.             frmClose.Dispose()
    5.         Next
    6.         With Frm
    7.             .MdiParent = MainForm
    8.             .Show()
    9.             .WindowState = FormWindowState.Maximized
    10.         End With
    11.     End Sub

    vb.net Code:
    1. Private Sub TsbTPR_Click(sender As Object, e As EventArgs) Handles TsbTPR.Click
    2.         ShowForm(FrmPermintaan)
    3.     End Sub

    When I click another form, it seems like the "form closing" process is not really neat and see some blink.

    Video: https://www.screencast.com/t/M8NYwOVDH

    Also, when I use the above code and I click the same form, it gives this error:
    Cannot access a disposed object.
    Name:  Screenshot_4.jpg
Views: 6562
Size:  30.7 KB

    Please help
    Attached Images Attached Images   

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width