realbasicrealstudio

REALBasic Questions


In REALBasic, how do I loop through all of the objects in Window1? Is there some array property of Window1 with all of its children? Also, how do you set custom properties of objects: e.g. Me.isFlamingo = true Thanks in advance!


Solution

  • To iterate through the controls on a window, use code like this:

      ListBox1.DeleteAllRows
    
      For i As Integer = 0 To Self.ControlCount-1
        ListBox1.AddRow(Self.Control(i).Name)
      Next
    

    (For this example, be sure to add at least one ListBox to the Window.)

    Properties are set just like you describe: ObjectInstance.PropertyName.

    If you are in the event of an object that has been dragged to the window, then you can modify its properties using Me.PropertyName. Otherwise you would use the object name.