| |

VerySource

 Forgot password?
 Register
Search
View: 586|Reply: 2

Ask the type (object) conversion again

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-11 14:40:01
| Show all posts |Read mode
Language: vb.net 2003
For example, one string in my database is "ItemNumber"
And this string happens to be the name of a MenuItem

After I get it out of the database, how do I associate it with MenuItem, for example, I want this Menuitem.Enable = False (normal case, ItemNumber.Enable = False)

But now ItemNumber is a string, is there any way to do it

I was prompted to do this
 Dim btn As Button = CType (Me.Controls.Find ("ItemNumber", True) (0), Button)
    If Not (btn Is Nothing) Then
        btn.Enabled = False
    End If
But Me.Controls.Find syntax error
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-2-7 16:00:02
| Show all posts
Why doesn't anyone know?
Reply

Use magic Report

1

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-10 20:15:02
| Show all posts
Iterate through the menu items to see which menu name is equal to the string you get from the database

Probably as follows:
Dim myMenuItem As MenuItem
For Each myMenuItem In Me.MainMenu.MenuItems
    If myMenuItem.Name = "ItemNumber" Then
     .................
    Else
     .................
    End If
Next
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list