Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27532

Having issues with MenuStrip control and subitems?

$
0
0
I have defined a menu structure with sub-items including ToolStripSeparators in my Windows VB.Net app. Based on users permissions, only some of the menu options will be viewable. I've got that working, however, after that routine is finished, I need to go back and loop thru each item and check to see if the last item in the sub-menu list is a a ToolStripSeparator. If it is, I need to make it invisible.

My problem is that in the following loop...none of the DropDownItems visible property shows as being visible. They are all false and I know there are some that are visible because they show up. What am I doing wrong? Here is my code!

Code:

                    Dim cnt As Integer = 0

                    For Each itm3 As ToolStripMenuItem In mnu.Items
                        cnt = itm3.DropDownItems.Count

                        Dim itm4 As Object

                        For Each itm4 In itm3.DropDownItems
                            If itm4.GetType = GetType(ToolStripSeparator) Then
                                itm4 = CType(itm4, ToolStripSeparator)
                            Else
                                itm4 = CType(itm4, ToolStripMenuItem)
                            End If

                            If itm4.visible = True Then
                                cnt += 1
                            End If
                        Next
                    Next


Viewing all articles
Browse latest Browse all 27532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>