Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Generic problem of VB.NET

Generic problem of VB.NET

Scheduled Pinned Locked Moved C#
tutorialcsharphelp
6 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    econy
    wrote on last edited by
    #1

    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:MenuExit

    I 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.

    P K L 3 Replies Last reply
    0
    • E econy

      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:MenuExit

      I 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.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Are you wanting to know how to do this in C#?

      E 2 Replies Last reply
      0
      • P Pete OHanlon

        Are you wanting to know how to do this in C#?

        E Offline
        E Offline
        econy
        wrote on last edited by
        #3

        Sure, Thanks. I rewrote my question. In fact, I don't want to create a new object, I just want to find the object with the name: xx-YY.

        1 Reply Last reply
        0
        • P Pete OHanlon

          Are you wanting to know how to do this in C#?

          E Offline
          E Offline
          econy
          wrote on last edited by
          #4

          I try to use Assembly.GetExecutingAssembly(). Thanks

          1 Reply Last reply
          0
          • E econy

            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:MenuExit

            I 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.

            K Offline
            K Offline
            Kenneth Haugland
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • E econy

              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:MenuExit

              I 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.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups