Form Unload in vb.net

Hi Experts,

I have tab control with 4 tabs. When I click the tab it loads a form. How can I unload the form when I go to the next tab.

Thank you.
RadhaKrishnaKiJayaAsked:
Who is Participating?
 
it_saigeConnect With a Mentor DeveloperCommented:
You could always use <yourformvariable>.Close(), e.g. -
' Make a variable that holds a reference to Tab Form instances.
Private tabForm As Form;
' Somewhere in your code, lets say a button click for TabOne
Private Sub OnTabOneButtonClick(ByVal sender As Object, ByVal e As EventArgs) Handles TabOneButton.Click
     tabForm = New TabOneForm()
     tabForm.Show()
End Sub

Private Sub OnTabSelected(ByVal sender As Object, ByVal e As TabControlEventArgs) Handles MainTabControl.Selected
     If Not tabForm Is Nothing
          tabForm.Close()
     End If
End Sub

Open in new window


This is completely untested and just off the top of my head.

-saige-
0
 
RadhaKrishnaKiJayaAuthor Commented:
Thank u very much for your help.
0
All Courses

From novice to tech pro — start learning today.