Paint in Canvas Array

I know the best way to add a picture to a canvas is via the Paint event using the following:

g.DrawPicture(tmpHandPic,0,0)

My question is how do I tell to it paint to a specific canvas control in the array?

I assume by “Array” you mean “Control Set” ?

if me.index = 1 then g.DrawPicture(tmpHandPic,0,0) end if

You can use a select case if you have several canvases.

[quote=284372:@Charles Fasano]I know the best way to add a picture to a canvas is via the Paint event using the following:

g.DrawPicture(tmpHandPic,0,0)

My question is how do I tell to it paint to a specific canvas control in the array?[/quote]

Global Property:
thePictureArray() as Picture // Assuming you have this loaded full of pictures

for i as integer = 0 to thePictureArray.Ubound
  Dim thePicXpos as Integer = 10 //some x value
  Dim thePicYpos as Integer = 10 // some y value
  Dim thePic as Picture = thePictureArray(i)

  g.drawpicture(thePic, thePicXpos, thePicYpos, thePic.width, thePic.height)

next i

// Use Canvas.Invalidate(False) to force a redraw

********** NOTE: I just realized you asked for drawing to a specific canvas control - Michel’s post is dead on there. Leaving my post for how to draw using a picture type array.

I thought I was supposed to use IF…Then or Select Case but for some reason I didn’t think it would work that way and it would draw the same picture to all canvas’s in the Array.

Although there is a unique event handler for all members, it fires separately for each.

I would modify Michel’s code to use “index” instead of “me.index”. Index is passed into the paint event for a control set.