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.
UPDATE: SOLUTION
I figured out a way to do what I want, and here is the solution
first this code is to add a ToolStripMenuItem to the mdiparent on form_load
Me.MdiParent = MDIParent1
mdf.BackColor = Color.Red
mdf.Text = Me.Text
AddHandler mdf.Click, AddressOf mdf1_Click
MDIParent1.MenuStrip.Items.Add(mdf)
then the ToolStripMenuItem click handler on the form
Private mdf As New ToolStripMenuItem
Private Sub mdf1_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.BringToFront()
End Sub
and this code is to remove the ToolStripMenuItem when the form is closed in (Form_formclosing) event
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
and to set the back color to red of the ToolStripMenuItem of the active form in MdiParent_MdiChilActivate event
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
and the result: (The active form is the red ToolStripMenuItem):