title: vb.net how I get a list of active and open forms in MDIparent inside MenuStrip Horizontally?
body: <p>Please, How I get a similar Open And Active child forms that are located in the "Windows" ToostripMenuItem in MdiParent as the picture below. but I want them horizontally, is there anyway to that? I appreciate your help.
  <a href="https://i.stack.imgur.com/AUmAG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AUmAG.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE: SOLUTION</strong><br>
  I figured out a way to do what I want, and here is the solution<br>
  first this code is to add a ToolStripMenuItem to the mdiparent on form_load</p>
  
  <pre><code>  Me.MdiParent = MDIParent1
      mdf.BackColor = Color.Red
      mdf.Text = Me.Text
      AddHandler mdf.Click, AddressOf mdf1_Click
      MDIParent1.MenuStrip.Items.Add(mdf)
  </code></pre>
  
  <p>then the ToolStripMenuItem click handler on the form</p>
  
  <pre><code>Private mdf As New ToolStripMenuItem
  Private Sub mdf1_Click(ByVal sender As Object, ByVal e As EventArgs)
      Me.BringToFront()
  End Sub
  </code></pre>
  
  <p>and this code is to remove the ToolStripMenuItem when the form is closed in (Form_formclosing) event</p>
  
  <pre><code>Try
          Dim ParentForm As MDIParent1 = MDIParent1
          Dim OptionsMenuStrip As MenuStrip = ParentForm.Controls("MenuStrip")
          Dim Items As ToolStripItemCollection = OptionsMenuStrip.Items
          Dim removeThese As New List(Of ToolStripMenuItem)
          For Each Item As ToolStripMenuItem In Items
              If Item.Text = Me.Text Then
                  removeThese.Add(Item)
              End If
          Next
          For Each item In removeThese
              Items.Remove(item)
              item.Dispose()
          Next
      Catch ex As Exception
          MsgBox(ex.Message)
  
      End Try
  </code></pre>
  
  <p>and to set the back color to red of the ToolStripMenuItem of the active form in MdiParent_MdiChilActivate event</p>
  
  <pre><code>Private Sub MDIParent1_MdiChildActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MdiChildActivate
      Try
          Dim activeChild As Form = Me.ActiveMdiChild
          Dim ParentForm As MDIParent1 = Me
          Dim OptionsMenuStrip As MenuStrip = ParentForm.Controls("MenuStrip")
          Dim Items As ToolStripItemCollection = OptionsMenuStrip.Items
          For Each Item As ToolStripMenuItem In Items
              If Item.Text = activeChild.Text Then
                  Item.BackColor = Color.Red
              Else
                  Item.BackColor = Color.LightGray
              End If
          Next
      Catch
      End Try
  End Sub
  </code></pre>
  
  <p>and the result: (The active form is the red ToolStripMenuItem):</p>
  
  <p><a href="https://i.stack.imgur.com/kpfzd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kpfzd.jpg" alt="enter image description here"></a></p>