Solved

using form1.Controls.Add question

Posted on 2001-07-21
2
167 Views
Last Modified: 2008-02-01
I want to use the frmDroppers.Controls.Add to add a number of picture boxes (50 or more) into a program during runtime, i want to be able to control each picturebox, how can i make the added control an array item? or whats the best way to add the controls?

curently i've been using:

   form1.Controls.Add "VB.Picturebox", "NewPic", PicSpace
   With form1!NewPic
      .Picture = pic1.Picture
      .AutoSize = 1
      .Left = 1925
      .BorderStyle = 0
      .Visible = True
   End With

(PicSpace is the name of the picturebox the picture is being created in and pic1 contains the picture to be placed into the new control.

Does this make sence?

thanks in advance
0
Comment
Question by:xizor
2 Comments
 
LVL 8

Accepted Solution

by:
glass_cookie earned 100 total points
ID: 6304936
How about trying this:

Create a picture box with index 0.

Then, add this code:

For i = 1 To 50 'Or whatever number you want
Load Picture(i)
Picture(i).Picture = pic1.Picture 'or maybe an array of pictures
Picture(i).AutoSize = 1
Picture(i).Left = 1925
Picture(i).BorderStyle = 0
Picture(i).Visible = True
Next i

That's it!

glass cookie : )
0
 

Expert Comment

by:BlackShark
ID: 6304961
hello xizor,

sorry i'm a newbie in vb and not sure about the best way..

add in design:
PicSpace.Index=0

add in your code:
Load PicSpace(PicSpace.Count) 'control with next index
With PicSpace(PicSpace.Count-1) 'use new control
     .Picture = pic1.Picture
     .AutoSize = 1
     .Left = 1925
     .BorderStyle = 0
     .Visible = True
End With
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 70
How to Add / Edit Windows Menu 4 74
Prevent user closing word document opened with VB6 6 84
Collapse and expand table in Word 2010 2 103
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question