Web 2.0 Control Properties

I want to iterate through the controls on a web page to get the coordinates of the labels and text fields and use these to build up a PDF one page report. Web 1 had the

for i = 0 to Me.ControlCount - 1

But there appears to be no support for Control.Count in Web 2. Is there another way to do this in Web 2?

Thanks for any help.

Perhaps this:

Ok, I see this, but how do you use it?

I have to agree with Graeme. The documentation on some parts of web 2.0 are more like a checklist than a language reference. That page doesn’t say much.


It looks like it’s an iterator so you would use a for each loop. It’s tough that reading the docs requires knowledge of the framework (chicken, egg), but here’s the relevant info for using an iterator: https://documentation.xojo.com/api/code_execution/iterable.html#iterable-iterator

1 Like

like any other iterator

for each ctl as WebControl in WebPage1.Controls
    // do what you need to do with ctl
1 Like

I can get the iterator to work, but how do I get access to the control’s properties, such as Top and Left?

You have to cast it to the correct type, just like before. RectControl has Top and Left properties.

For Each c As Control In Self.Controls
  If c IsA RectControl Then
    var Top as Integer = RectControl(c).Top

Almost right. Replace RectControl with WebUIControl. That’s where the coordinate info lives.