Is there a way to handle multiple Controls similarly to Control Arrays?

Hello all,

Xojo 2023R3 - it appears that Control Arrays are not supported. Anyone know when this might change?

Is there an alternative method especially when loading or saving I have always used a For Next loop such as:

For i As Integer  = 1 To 11
  CmbStart(n).AddRow  Cstr(i) + ":00" ' AM"
  CmbStart(n).AddRow  Cstr(i) + ":15" '  AM"
  CmbStart(n).AddRow  Cstr(i) + ":30" '  AM"
  CmbStart(n).AddRow  Cstr(i) + ":45" '  AM"
Next i

Ideas appreciated!
Thanks,
Tim

You can create a control subclass and use it to locate controls of this group for example

Var n As Integer = 0
For Each cntrl As WebUIControl In Self.Controls
  If cntrl IsA MyTextField Then
    n = n + 1
    MyTextField(cntrl).Caption = "Init "+n.ToString
  End
Next

image

1 Like

Hi Rick

Thank you! That looks like a really easy and elegant method.

Much appreciated!
Tim

1 Like

I made a Feature Request last year: https://tracker.xojo.com/xojoinc/xojo/-/issues/70810

But there is another one that is more than 2 years old:
https://tracker.xojo.com/xojoinc/xojo/-/issues/64653

Looks like that someone at xojo cant understand why users want Control Arrays, so dont hold your breath on this. Web2 is still feature incomplete, Im still on web1 for now.

Hi Guys,

A few questions
@ Rick A - When wanting to read the value of a WebPopupMenu, and there are more than what you want to read at this time, how to identify them?

@ Ivan Tellez thank you also for responding. I suppose we can hope!

Tim

when playing with webpopupmenus (and other menus) you always have the rowtag property where you can store a unique id to identify the line that was choosen.

1 Like

Hi Jean-Yves Pochez

There’s no row tag property available on WebPopupMenus - at least not in 2023R3 or 3.1

Wish this was simpler, like the good ole days!

Tim

Uh, where did you get that idea?
WebPopupMenu.RowTagAt is both in the documentation and autocomplete.

Hi Tim,

Maybe it was my confusion, but the “RowTag” only identifies the line the was chosen. In this case, it needs to ID the WebPopupMenu object itself. I saw no way to do that - ie set a property to each WebPopupMenu - not it’s contents. Similar to having an array of WebPopupMenus like in Web1

Tim

1 Like

You could do something like this, but you should probably revisit your design if this achieves what you want:

// The items in the array are WebPopupMenus on the WebPage
var aroMenus() as WebPopupMenu = Array(WebPopupMenu1, WebPopupMenu2, WebPopupMenu3)

for each oMenu as WebPopupMenu in aroMenus
  for i as Integer = 1 to 11
    oMenu.AddRow(i.ToString + ":00")
    oMenu.AddRow(i.ToString + ":15")
    oMenu.AddRow(i.ToString + ":30")
    oMenu.AddRow(i.ToString + ":45")
  
  next i

next oMenu

A TimeMenu subclass would be recommended, or finding some better way to enter times. The way Indeed has you select availability is an absolute pain.

Assigning is relatively easy. Its reading the values of each that are a PIA.

Your reference to TimeMenu Subclass - is this a subclass that I would create

Tim

Rick gave you a pretty good answer. Make a subclass and use it only for the controls you want in the controlarray. If you want a different control array, create another subclass. Then you can loop through all the controls and identify which ones are in the control array by examing their control type.

1 Like

Hi Tim,

Yes, I will be looking into that.

Thanks,
Tim

Thank you!
Tim

1 Like