CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2005
    Posts
    200

    Red face Is it possible to create Pictureboxes during run time?

    Hi,

    Is it possible to create Pictureboxes during run time?

    During design time, there is only 1 picturebox on the form but when the application is running, I would like to add more pictureboxes 'on the fly'.

    Can this be done in vb.net?

  2. #2
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: Is it possible to create Pictureboxes during run time?

    intialize new pictureBox object
    Code:
    dim newPictureBox as PictureBox
    newPictureBox= new PictureBox()
    set its properties
    Code:
    newPictureBox.Parent=me
    newPictureBox.Location=new Point(10,10)
    newPictureBox.Size=new Size(100,100)
    add it to parent controls
    Code:
    Me.Controls.Add(newPictureBox)

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Is it possible to create Pictureboxes during run time?


  4. #4
    Join Date
    Apr 2005
    Posts
    200

    Re: Is it possible to create Pictureboxes during run time?

    Thanks for the replies!

    And to remove controls during run time, the code will be:

    Me.controls.remove(Picturebox1) right?

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

Featured