Most .NET indexed properties are default indexed properties for collections. A collection is a class that implements the following interfaces:

  • System.Collections.ICollection
  • System.Collections.IEnumerable
  • System.Collections.IList

Some commonly used methods and properties of a collection class include:

  • Add( ) method — For adding objects to a collection, as follows:
    USING System.Windows.Forms.* FROM ASSEMBLY.
    
    DEFINE VARIABLE myControls AS CLASS Control+ControlCollection NO-UNDO.
    DEFINE VARIABLE myForm     AS CLASS Progress.Windows.Form     NO-UNDO.
    DEFINE VARIABLE myButton   AS CLASS Button                    NO-UNDO.
    
    ASSIGN
      myForm        = NEW Progress.Windows.Form( )
      myButton      = NEW Button( )
      myButton:Text = "Ok".
    
    /* Controls property references a ControlCollection object */
    myControls = myForm:Controls.
    myControls:Add(myButton).
    Note: Progress.Windows.Form is an OpenEdge .NET form class that inherits from System.Windows.Forms.Form. For more information, see Create and use forms and controls.
  • Contains property — To determine if a particular object is in the collection, as follows:
    IF myControls:Contains(myButton) THEN
      MESSAGE "myControls has a myButton object" VIEW-AS ALERT-BOX.
  • Count property — To determine how many objects there are in the collection, as follows:
    MESSAGE "myControls has " myControls:Count " objects." VIEW-AS ALERT-BOX.
  • Item property — The default indexed property to access a particular object in the collection. Some collections overload this property. However, they all have one Item property that is indexed on a zero (0)-based INTEGER key, as follows:
    MESSAGE "Control #0 Text: " myControls[0]:Text VIEW-AS ALERT-BOX.
  • Remove( ) method — For removing an object from a collection, as follows:
    IF myControls.Contains (myButton) THEN
      myControls:Remove(myButton).
    
    MESSAGE "myControls has " myControls:Count " objects." VIEW-AS ALERT-BOX.

For more information on collections, see the .NET documentation for a particular .NET collection class and the ICollection, IEnumerable, and IList interfaces in the System.Collections namespace. For more information on locating this documentation, see OpenEdge-installed .NET Controls.