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. programatically creating control instances

programatically creating control instances

Scheduled Pinned Locked Moved C#
questionhelptutorial
3 Posts 2 Posters 0 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.
  • P Offline
    P Offline
    Pyro Joe
    wrote on last edited by
    #1

    Hi, yeah I need to know how to create an instance of a control programatically. I know one can do soemthing like "TextBox tb = new TextBox();" but this has to be done in the initialization section fo the class, and if it's written within a method, it's only available for within that method. But this isn't the main problem, the main thing is that I don't necessarily know how many of a certain control will be needed, so how do I create new control on demand with a name either generated, or taken from user input via a textbox or something? Thanks, Stephen

    L 1 Reply Last reply
    0
    • P Pyro Joe

      Hi, yeah I need to know how to create an instance of a control programatically. I know one can do soemthing like "TextBox tb = new TextBox();" but this has to be done in the initialization section fo the class, and if it's written within a method, it's only available for within that method. But this isn't the main problem, the main thing is that I don't necessarily know how many of a certain control will be needed, so how do I create new control on demand with a name either generated, or taken from user input via a textbox or something? Thanks, Stephen

      L Offline
      L Offline
      Luke Davis
      wrote on last edited by
      #2

      MSDN[^] has a good article.

      P 1 Reply Last reply
      0
      • L Luke Davis

        MSDN[^] has a good article.

        P Offline
        P Offline
        Pyro Joe
        wrote on last edited by
        #3

        This article doesn't work. I think something between vs '03 and vs '05 has changed. It wants me to create a ButtonArray, which does not exist. Here is what they have in the example: // Declare a new ButtonArray object. ButtonArray MyControlArray; MyControlArray = new ButtonArray(this); // Call the AddNewButton method of MyControlArray. MyControlArray.AddNewButton(); Well seeing how the ButtonArray thing doesn't exist, I can't really do anything with this. How do I go about creating control collections in visual studio 2005?

        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