Generic problem of VB.NET
-
I have some strings to represent the names of forms and controls. for example; MenuLogin = name of an instance of System.Windows.Forms.MenuItem Now I want to assign Text value to the object whose name is the string at run time. I.e:
s1 = "MenuExit"
Object(s1).Text = Exit login window //find an object,Name:MenuExitI can't find a method in the Object that can search an object with name "MenuExit" in the application. Please tell me how to implement it, thanks.
-
I have some strings to represent the names of forms and controls. for example; MenuLogin = name of an instance of System.Windows.Forms.MenuItem Now I want to assign Text value to the object whose name is the string at run time. I.e:
s1 = "MenuExit"
Object(s1).Text = Exit login window //find an object,Name:MenuExitI can't find a method in the Object that can search an object with name "MenuExit" in the application. Please tell me how to implement it, thanks.
Are you wanting to know how to do this in C#?
-
Are you wanting to know how to do this in C#?
-
Are you wanting to know how to do this in C#?
-
I have some strings to represent the names of forms and controls. for example; MenuLogin = name of an instance of System.Windows.Forms.MenuItem Now I want to assign Text value to the object whose name is the string at run time. I.e:
s1 = "MenuExit"
Object(s1).Text = Exit login window //find an object,Name:MenuExitI can't find a method in the Object that can search an object with name "MenuExit" in the application. Please tell me how to implement it, thanks.
I think you misunderstood Pete's comment, this is a C# forum, and your question is Visual Basic. There is a designated forum for VB questions. As for your question; I'm not entirely sure what you want, WinForms are not my expertise. It seems like the .Text method does not exists in s1.
-
I have some strings to represent the names of forms and controls. for example; MenuLogin = name of an instance of System.Windows.Forms.MenuItem Now I want to assign Text value to the object whose name is the string at run time. I.e:
s1 = "MenuExit"
Object(s1).Text = Exit login window //find an object,Name:MenuExitI can't find a method in the Object that can search an object with name "MenuExit" in the application. Please tell me how to implement it, thanks.
econy wrote:
I can't find a method in the Object
You annot assume that
Object
will contain such a method; and where would it search for these items? You would need to first create some type of List that contains all the Objects, which you then search by name.