Click to See Complete Forum and Search --> : drawing


ariel_au
March 29th, 2001, 01:10 AM
i created a form called formMain. inside this form i created a picture box.
inside the picture box, i created a image box and set the index property of the image box to 0.
my problem is that how can i draw 20 image boxes (row 5, col 4) in the picture box?

Clearcode
March 29th, 2001, 02:45 AM
Dim nRow as Integer, nCol as Integer
Dim nIndex as Integer

for nRow = 1 to 5
for nCol = 1 to 4
'\\ If no image box, load a new one
If imgControl.count = nIndex then
Load imgControl(nIndex)
End If
'\\ Move the control to the correct place
imgControl(nIndex).Top = (nRow -1) * imgControl(0).Height
imgControl(nIndex).Left = (nCol-1) * imgControl(0).Width
'\\ Increment the control index
nIndex = nIndex + 1
next nCol
next nRow





This assumes that your image control is called imgControl

HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

ariel_au
March 29th, 2001, 03:03 AM
your code draws only 1 imgbox.
i typed ur code in Private Sub Form_Load()
and i set the imgbox index property to 0.
what went wrong?

Clearcode
March 29th, 2001, 03:23 AM
In order to see the control you need to set it's visible property to true thus:

for nRow = 1 to 5
for nCol = 1 to 4
'\\ If no image box, load a new one
If imgControl.Count = nIndex then
Load imgControl(nIndex)
End If
'\\ Move the control to the correct place
imgControl(nIndex).Top = (nRow - 1) * imgControl(0).Height
imgControl(nIndex).Left = (nCol - 1) * imgControl(0).Width
'\\ make the image control visible
imgControl(nIndex).Visible = true
'\\ Increment the control index
nIndex = nIndex + 1
next nCol
next nRow




HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com