Problem iterating through controls

Was iterating through the controls in a window. Crash.

The problem seems to be that doing

for each dc as DesktopControl in self.controls
// do something useful here
next

does not work if there is a DesktopContainer. It appears a DesktopContainer is not a DesktopControl. The issue is that the documentation states that self.controls consists of DesktopControls.

I was able to work around this by iterating through the controls using self.controlAt(i). It was then possible check the type before attempting to do something with it.

Hope this helps.

For each o As Object in self.Controls
  
  If o isA DesktopControl Then
    
    Var dc As DesktopControl = DesktopControl(o)
    
    break
    
  ElseIf o IsA DesktopContainer Then
    
    Var dct As DesktopContainer = DesktopContainer(o)
    
    Break
    
  Else
    
    MessageBox "What is that?"
    Quit
    
  End
  
Next
1 Like

I was about to start typing when Rick chimed in, and I like his better. :slight_smile:

1 Like

This works, but the problem still remains in the documentation.

Open an Issue Report

Ask for proper amendments at DesktopWindow — Xojo documentation

I appears I still have editing permissions on https://docs.xojo.com/ - if you tell me what needs changing…
Or is that not the corrent docs site any more? There were so many, I’ve lost track.

Oh, indeed - it’s now https://documentation.xojo.com – and I cannot login there any more.

The current way is explaining what’s wrong and requesting changes as Issues Reports as those:

https://tracker.xojo.com/xojoinc/xojo/-/issues/?label_name[]=Documentation

Yeah, have fun with that :slight_smile:

Seriously, when it was a Wiki that some of us were trusted with to edit, I often fixed things right when I saw them. This going thru a “feedback” report is not something I’d ever do - too much hassle, and they it still may not happen, or done wrong.

3 Likes

:person_shrugging:t2: :ok:

That’s one of the nice things about the PHP docs - user contributions are possible.