hi!,

i have MDI form(Form1) which contain some toolstripmenu item.
for example menu_101.

if i do "Form1.menu_101.enabled=True" its working fine.

my problem is i have a string variable like "menuname" which contain
like
menuname=menu_101

i need to enable or disable using this string variable like
"Form1.menuname.enabled=True"

please anyone knows let me know...
thanks

hmm i have solved that problem in the past like this

Dim menuStrip As Contexmenu= DirectCast(Form1.Controls.Find(menuname, True)(0), Contexmenu)
menuStrip.Enable=True

hmm i have solved that problem in the past like this

Dim menuStrip As Contexmenu= DirectCast(Form1.Controls.Find(menuname, True)(0), Contexmenu)
menuStrip.Enable=True

I tried like what u give
' Dim menuStrip As ContextMenu = DirectCast(Form1.Controls.Find(menuname, True)(0), ContextMenu)
menuStrip.Enabled = True '

but it shows the error like below

"value of type 'System.Windows.Forms.Control' cannot be
converted to 'System.Windows.Forms.ContextMenu'".

please tell me what should i do?

thanks

just checked it again. sorry was my fault. contexmenus arent controls

here is a working example

Dim menustrip As String = "ContextMenuStrip1"

        For Each cntrl As Control In Me.components.Components
            If cntrl.Name = menustrip Then
                'do what ever you need to do 
                Exit For
            End If
        Next

I have a Menustrip and the MenuStrip contain 9 items.
In each item contain subitem.
I want to disable sum subitem when I select from database to compare with the subitem name.
how can I do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.