Solved

No 'check' property for Menustrip DropDownItems created at runtime

Posted on 2014-11-21
2
149 Views
Last Modified: 2014-11-21
Hi experts,

I need to add an array of menu dropdownitem at runtime to a menuitem created at design time.
The problem is: I can't find the property ‘check’  in my array of dropdownitem in its click event. I want the fired dropdownitem checked and all other dropdownitem in the same array uncheched.

Below is my code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For X = 0 To 5
            Dim NewMenuItem As New ToolStripMenuItem("Option" & X + 1, Nothing, New EventHandler(AddressOf Option_Click))
            NewMenuItem.Tag = X
            OptionToolStripMenuItem.DropDownItems.Add(NewMenuItem)
        Next
    End Sub

    Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        For X = 0 To OptionToolStripMenuItem.DropDownItems.Count - 1
            OptionToolStripMenuItem.DropDownItems(X).BackColor = Color.White
          'want check property instead of highlighted with color
        Next
        OptionToolStripMenuItem.DropDownItems(sender.tag).BackColor = Color.Blue
    End Sub
0
Comment
Question by:LoGa1234567890
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
louisfr earned 500 total points
ID: 40457053
Cast the item to the right type.
For example:
Dim menuItem = DirectCast(OptionToolStripMenuItem.DropDownItems(X), ToolStripMenuItem)
menuItem.Checked = True

Open in new window

0
 

Author Closing Comment

by:LoGa1234567890
ID: 40457083
Thank you !
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question