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. Visual Basic
  4. Using a loop to create multiple controls at runtime?

Using a loop to create multiple controls at runtime?

Scheduled Pinned Locked Moved Visual Basic
comhelpquestion
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.
  • J Offline
    J Offline
    Jm6k
    wrote on last edited by
    #1

    Is there a way that I could create multiple contols on a form using a loop? for loopcounter = 1 to 10 dim strControlName as string = "Button" dim objButton as new button() objbutton.name = strControlName & loopcounter form1.controls.add(objbutton) next Am I close? Please help! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

    D 1 Reply Last reply
    0
    • J Jm6k

      Is there a way that I could create multiple contols on a form using a loop? for loopcounter = 1 to 10 dim strControlName as string = "Button" dim objButton as new button() objbutton.name = strControlName & loopcounter form1.controls.add(objbutton) next Am I close? Please help! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

      D Offline
      D Offline
      dynamic
      wrote on last edited by
      #2

      you would need to make the controls globally available ( not just on a sub or command button ) and also you would have to account for setting the positions of each item, which could become a bit of a headache. can you not add the controls at design time? it would save you a lot of bother.


      Private void ExpectingTwins(string twins)
      {
      switch(twins)
      {
      Case ("twins on the way"):
      MessageBox.Show("for mr and mrs dynamic","twins on the way");
      break;
      }
      }


      J 1 Reply Last reply
      0
      • D dynamic

        you would need to make the controls globally available ( not just on a sub or command button ) and also you would have to account for setting the positions of each item, which could become a bit of a headache. can you not add the controls at design time? it would save you a lot of bother.


        Private void ExpectingTwins(string twins)
        {
        switch(twins)
        {
        Case ("twins on the way"):
        MessageBox.Show("for mr and mrs dynamic","twins on the way");
        break;
        }
        }


        J Offline
        J Offline
        Jm6k
        wrote on last edited by
        #3

        I was just wondering if it could be done, I realize that it would take some work to do the location of the controls. You said globally? Thanks! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

        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