No Container Control Arrays?

  1. 3 months ago

    Dave S

    Jun 6 San Diego, California USA
    Edited 3 months ago

    I created a custom control (a container control with a textfield, canvas and scrollbar)
    and needed two on a window... but I cannot make a control array???? What?

    so I need to do

    xyz1.dosomething()
    xyz2.dosomething()

    instead of

    for i=0 to 1
    xyz(i).dosomething
    next i

    while the above seems trivial, the completed app needs to manipulate those two instances dozens of ways under as many circumstances

    probably going to have to do this

    function getControl(index) as myContainer
    select case index
    case 0
    return xyz1
    case 1
    return xyz2
    end function

    opted for a function that returns the instance based on an index.... performs the same function as a control array would

  2. Tim P

    Jun 6 Pre-Release Testers Rochester, NY
    Edited 3 months ago

    I'm pretty sure that's documented somewhere.

    You can work around it. ContainerControls don't need to be in an existing control-array to create instances on the fly. Just make an array property - you'll need to store references to the containers you embed anyway. You'd be able to loop through the array to DoSomething.

    for i as Integer = 0 to aroContainerArrayProperty.Ubound
      aroContainerArrayProperty(i).DoSomething
    next
  3. Bob K

    Jun 6 Pre-Release Testers, Xojo Pro, Third Party Store Kansas City

    I would argue that it makes more sense for you to have your own array for ContainerControls anyway. They are not traditional controls and are really special windows.

  4. Dave S

    Jun 6 Answer San Diego, California USA

    opted for a function that returns the instance based on an index.... performs the same function as a control array would

  5. To make ContainerControl Arrays:
    In your ContainerControl make a Property called "Index" if that doesn't exist. Select this ContainerControl and choose "Inspector Behavior...". Check the "Index" property and close it. Now when you go to the second page of "Inspector" in the IDE, you're able to make it a member of a Control Set and create more instances.
    However, you can't refer in your code to "Index". It will give you a wrong number. Instead, use an extra Property, something like "id" or so and use that to detect which item is selected.

or Sign Up to reply!