title: Close opened form in SplitContainer Panel2 in VB.NET
body: <p>Need some help in the VB.NET, not sure where I am doing wrong</p>
  
  <p><strong>Background:</strong> I have a master form which uses the SplitContainer control. The PANEL1 of the split carries the MenuStrip and Panel2 is used to call related external forms <img src="https://i.stack.imgur.com/Oge2Y.gif" alt="enter image description here"></p>
  
  <p><strong>Code (refer below):</strong> Function <code>ResetSplitContainerPanel2</code> clears the Panel2 and loads the new form using the <code>SetFormAttributesToLoadInPanel2</code></p>
  
  <p><strong>Issue:</strong> Although <code>SettingSplitContainer.Panel2.Controls.Clear()</code> clears the Panel2 but the form still maintains the form in the editable mode. If I call the same form again, I can see the values which I typed earlier</p>
  
  <p><strong>Output Expected:</strong> On Load of new form, the previous loaded form in PANEL2 should be disposed completely</p>
  
  <pre><code>Private Sub ResetSplitContainerPanel2()
      SettingSplitContainer.Panel2.Controls.Clear()
  End Sub
  
  Private Function SetFormAttributesToLoadInPanel2(ByVal formNameToChange As Form) As Boolean
          On Error GoTo errHandler
  
          formNameToChange.IsMdiContainer = False
          formNameToChange.ShowInTaskbar = False
          formNameToChange.FormBorderStyle = Windows.Forms.FormBorderStyle.None
          formNameToChange.ControlBox = False
          formNameToChange.TopLevel = False
          formNameToChange.Text = ""
          formNameToChange.Visible = True
          formNameToChange.Width = SettingSplitContainer.Panel2.Width
          formNameToChange.Height = SettingSplitContainer.Panel2.Height
  
          SetFormAttributesToLoadInPanel2 = False
          Exit Function
  
  errHandler:
          MsgBox("Error Description: " &amp; Err.Description, vbOKOnly, "Error")
          SetFormAttributesToLoadInPanel2 = True
          Exit Function
      End Function
  </code></pre>
  
  <p>Appreciate your help</p>