Duplicate an object or control

The frmForm has a red Rectangle named rectangleTemplate

How would you guys duplicate arrays of this rectangle “on-the-fly” ?

For i As Integer = 1 to 10 Dim square As Rectangle = New rectangleTemplate If i = 1 Then square.left = 5 Else square.left = square(i - 1).left + 5 End If Next

Xojo says there is no class with this name.

Give the original an index value of 0

Hmm, now I get a syntax error for Dim square As Rectangle = New rectangleTemplate

Dim square As rectangleTemplate = New rectangleTemplate

perhaps… it depends on whether rectangletemplate is a rectangle or a new class derived from rectangle.

What is the error?

Its almost the same question as your other post about creating a new window, except that you dont need to index windows.
The point there was you dont create a new Window, you create a new frmMySpecialKindOfWindow

You must first click the gear icon in the inspector and make the rectangle member of a control set.

Then you can dim as many instances of the rectangle as you want. Remember to position them elsewhere, otherwise they appear on top of member(0).

Thanks guys, @Michel Bujardet got it! Didn’t knew I had to do this :slight_smile: Thanks