Results 1 to 5 of 5

Thread: Creating new Picture Box

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Lebanon,Beirut
    Posts
    48

    Creating new Picture Box

    HI there, ill explain my problem in the following exple:

    for i=1 to 10

    ' i need to create a picturebox(i) that are visible on the current form

    loop


    what i did is the following:

    Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
    Me.PictureBox2 = New System.Windows.Forms.PictureBox()
    Me.PictureBox2.BackColor = System.Drawing.SystemColors.Desktop
    Me.PictureBox2.Location = New System.Drawing.Point(85, 124)
    Me.PictureBox2.Name = "PictureBox2"
    Me.PictureBox2.Size = New System.Drawing.Size(40, 40)

    and i added it to the PUBLIC SUB NEW()
    but for some reasons, i dont get any errors but picturebox2 is not showing (not visible), pleaz guys i cld really need your help.

    thank you ...
    There is,we are,abou il zoulouf,mijana w mal3ona

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You left this one out : It add your control to the form control collection : It should be the last line of your code .

    VB Code:
    1. Me.Controls.Add(PictureBox2)

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Lebanon,Beirut
    Posts
    48
    Thank you Pirate for yr reply, but the new problem im facing is that i need to define X number of picture box , how can i do that in the form_load? i need to put it in a for loop.

    thank you
    There is,we are,abou il zoulouf,mijana w mal3ona

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Here is a demo shows you how to create arrays of picturebox control .
    Attached Files Attached Files

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Update 1

    This is more dynamic . You can specify number of pictureboxes along with X & Y Coordinates at runtime.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width