Link to home
Start Free TrialLog in
Avatar of trevorm
trevorm

asked on

VB 4.0 - Creating Objects on the Fly

I have a situation where I want to create a releated object for each database record I read in. Basically I want to create probably a picture box or image for each record read in. Each record may have an associated BMP.

In reading the records from the table I want to create an object for each an load this onto the form. The will have to be moveable as I want to be able to drag & Drop these into a certain position.

I will give you an example.  I have a sports Database where there are teams entered.  For each round in the competition I want the user to be able to associate the teams playing each other. I want to create an object for each team on the right part of the form then associated Home & Away playing team in the left part of the form.

Thanks in Advance
Avatar of dansari
dansari

trevorm:

Why don't you store the X and Y coordinates (Left and Top properties) of each picture box control in the database?  In the Form_Unload event (or using a Save button, or something), you can save the values.

If the number of players and teams is fixed, then you can create the picture box controls at design time; otherwise, you can use control arrays.

Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of hfanan
hfanan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's another trick.  Make your data structures do the work.  Put the file name of the bmp, or the icon name if using an image list, in your records.  That way when you read the record, it defines its own image.  Then if you want to change images, just refile another .bmp under the same file name on your drive.