Window Tool Strip Menu Items

  • Thread starter Thread starter Bill Schanks
  • Start date Start date
B

Bill Schanks

In my tool strip menu items, I have a window option and it fills when
clicked with the active windows in the appliation. It works fine, but
I want the item to be checked if it's active. Here is my code:

What I have tried to do is:
Me.WindowToolStripMenuItem.DropDownItems.Item(x).checked = true

But .checked is not an option. Am I building the dropdown the wrong
way to be able to do this?

Private Sub WindowToolStripMenuItem_DropDownOpening(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
WindowToolStripMenuItem.DropDownOpening

'Clear list
Me.WindowToolStripMenuItem.DropDownItems.Clear()

Dim x As Short = 0
Dim frmAnnc As frmDocument
Dim frmResults As frmResults
Dim frmRpt As frmRpt

'Fill in with open forms
For Each f As Form In My.Application.OpenForms
Dim annc As frmDocument = TryCast(f, frmDocument)
Dim result As frmResults = TryCast(f, frmResults)
Dim report As frmRpt = TryCast(f, frmRpt)

'Annc forms
If annc IsNot Nothing Then
frmAnnc = annc
Me.WindowToolStripMenuItem.DropDownItems.Add(CStr(x + 1) & " " &
frmAnnc.Text)
Me.WindowToolStripMenuItem.DropDownItems.Item(x).Tag = frmAnnc.Text
If frmAnnc.Text = g_ActiveForm Then
Me.WindowToolStripMenuItem.DropDownItems.Item(x).Font = _
New System.Drawing.Font("Tahoma", 8.25!,
System.Drawing.FontStyle.Bold, _
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
End If
x += 1
End If

'Result forms
If result IsNot Nothing Then
frmResults = result
Me.WindowToolStripMenuItem.DropDownItems.Add(CStr(x + 1) & " " &
frmResults.Text)
Me.WindowToolStripMenuItem.DropDownItems.Item(x).Tag =
frmResults.Text
If frmResults.Text = g_ActiveForm Then
Me.WindowToolStripMenuItem.DropDownItems.Item
(x).Font = _
New System.Drawing.Font("Tahoma", 8.25!,
System.Drawing.FontStyle.Bold, _
System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
End If
x += 1
End If

'Report forms
If report IsNot Nothing Then
frmRpt = report
Me.WindowToolStripMenuItem.DropDownItems.Add(CStr(x + 1) & " " &
frmRpt.Text)
Me.WindowToolStripMenuItem.DropDownItems.Item(x).Tag =
frmRpt.Text
If frmRpt.Text = g_ActiveForm Then
Me.WindowToolStripMenuItem.DropDownItems.Item
(x).Font = _
New System.Drawing.Font("Tahoma", 8.25!,
System.Drawing.FontStyle.Bold, _
System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
End If
x += 1
End If
Next

End Sub
 
I found it for anyone interested:

CType(Me.WindowToolStripMenuItem.DropDownItems.Item(x) _
, ToolStripMenuItem).Checked = True
 
Back
Top