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. Windows Forms
  4. dynamic pictureBox creation

dynamic pictureBox creation

Scheduled Pinned Locked Moved Windows Forms
5 Posts 3 Posters 17 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.
  • S Offline
    S Offline
    sarah_malik
    wrote on last edited by
    #1

    Hi all, I have a form that contains one button and one textbox, the textbox will take a number that will be passed to another form. I have done this successfully. The thing is that I need the second form to create a number of pictureboxes = the number received from the first form. Any ideas?

    J 1 Reply Last reply
    0
    • S sarah_malik

      Hi all, I have a form that contains one button and one textbox, the textbox will take a number that will be passed to another form. I have done this successfully. The thing is that I need the second form to create a number of pictureboxes = the number received from the first form. Any ideas?

      J Offline
      J Offline
      JUNEYT
      wrote on last edited by
      #2

      If you are dealing with VB.Net the sample approach can give so some insight how to do that. But you should consider defining location, size, back color information for a specific picturebox which you get it from an array. The sample will rename the each picturebox automatically. :wtf:

      Dim GetNumber as New Int32 = PutHereHowManyYouWant
      Dim I as Int32
      
      
      For I = 1 to GetNumber
      
          Dim NewPicBox as New PictureBox
      
          NewPicBox.Name = "NewPicBox_" + I.toString
          NewPicBox.Size = New Size (PWidth(I), PHeight(I))
          NewPicBox.Location = New Point (PX(I), PY(I))
          NewPicBox.BackColor = color.From.ArgB(P1(I),P2(I),P3(I))
      
          Me.Controls.Add(NewPicBox)
      
          'Here you should create an addhandler and out eventhandler procedure
          to control each picture box.
      
          Next
      

      What a curious mind needs to discover knowledge is noting else than a pin-hole.

      S 1 Reply Last reply
      0
      • J JUNEYT

        If you are dealing with VB.Net the sample approach can give so some insight how to do that. But you should consider defining location, size, back color information for a specific picturebox which you get it from an array. The sample will rename the each picturebox automatically. :wtf:

        Dim GetNumber as New Int32 = PutHereHowManyYouWant
        Dim I as Int32
        
        
        For I = 1 to GetNumber
        
            Dim NewPicBox as New PictureBox
        
            NewPicBox.Name = "NewPicBox_" + I.toString
            NewPicBox.Size = New Size (PWidth(I), PHeight(I))
            NewPicBox.Location = New Point (PX(I), PY(I))
            NewPicBox.BackColor = color.From.ArgB(P1(I),P2(I),P3(I))
        
            Me.Controls.Add(NewPicBox)
        
            'Here you should create an addhandler and out eventhandler procedure
            to control each picture box.
        
            Next
        

        What a curious mind needs to discover knowledge is noting else than a pin-hole.

        S Offline
        S Offline
        sarah_malik
        wrote on last edited by
        #3

        hi JUNEYT actually I'm using C++.NET thanks anyway,

        D 1 Reply Last reply
        0
        • S sarah_malik

          hi JUNEYT actually I'm using C++.NET thanks anyway,

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Then ask in the Visual C++/CLI Forum[^].

          Dave Kreskowiak Microsoft MVP - Visual Basic

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Then ask in the Visual C++/CLI Forum[^].

            Dave Kreskowiak Microsoft MVP - Visual Basic

            S Offline
            S Offline
            sarah_malik
            wrote on last edited by
            #5

            ok, I will. Thanks all,

            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