Results 1 to 3 of 3

Thread: [RESOLVED] ToolStripMenuItem cast problem

  1. #1

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Resolved [RESOLVED] ToolStripMenuItem cast problem

    I have this code:
    Code:
    For Each oToolStripMenuItem As ToolStripMenuItem In oToolStripMenuItemMain.DropDownItems
      '...
    Next
    First line produces an exception because it runs into a ToolStripSeparator. Any ideas how to modify this loop so it won't?

    Ty

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: ToolStripMenuItem cast problem

    Try this:

    Code:
    For Each oToolStripMenuItem As ToolStripMenuItem In oToolStripMenuItemMain.DropDownItems.OfType(Of ToolStripMenuItem)()
      '...
    Next

  3. #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width