Skip to content

Class: List

Properties | Events | Methods | Index of Classes

Manipulates dynamic lists of information

Hierarchy

cObject > cUIObject > DfBaseObject > DfBaseWindow > DfBaseUIWindow > DfBaseControl > DfBaseList > DfBaseListbox > List

Show full hierarchy and direct subclasses

Library: Windows Application Class Library

Package: Windows.pkg

Mixins: Standard_Object_Mixin, Dflabel_Mixin, Multi_Item_Shadow_Mixin

Description

This class is obsolete. It has been replaced by the cCJGrid class.

As of revision 16.0, DataFlex includes full support for Codejock Software's COM Report Control package for creating grids. See Using Grids for more information.

List is used to manipulate and display lists of information. This control class is designed to add, insert, delete and sort items. In addition, the List class uses a scrollbar object to allow users to see more information and use the mouse to navigate through the list. List objects display a list of items in single column and allow the user to select one or more items in the List.

Syntax

Use dfbase.pkg
Object oContainer is a ContainerClass
    :
    Object oObjectName is a List
        Set Size to height width
        Item_List
            On_Item [prompt [Send message [of dest_object]]]
            :
        End_Item_List
    End_Object
End_Object

Argument Explanation

Col 1 Col 2
Container The object that contains the List object.
ContainerClass The class (Panel or BasicPanel) of Container.
object_name The name of the List object.
height The height of object_name.
width The width of object_name.
prompt The prompt to display in an item.
messages A message to send when an item is chosen.
dest_object An object to which message is sent.

Sample.

Use Windows.pkg

Object oDialog is a ModalPanel
    Set Size to 10 40
    Set Caption_Bar to true    
    Set Label to "Mechanic Checklist"
    Object oList is a List
        Set Size to 80 50
        Item_List
            On_Item "Oil Filter" send None
            On_Item "Spark Plugs" send None
            On_Item "Tire pressure" send None
            On_Item "Brake pad" send None
            On_Item "Exhaust" send None
            On_item "Radiator" send None
        End_Item_List
    End_Object
End_Object

Start_Ui oDialog

Sample.

This sample code shows a view that will allow the user to enter a directory name and file filter (e.g. "c:\windows*.exe") and refesh the list when navigating into it (via Tab).

Use DfAllEnt.Pkg
Use Seq_Chnl.Pkg // Package with I/O channel management functions

ACTIVATE_VIEW Activate_oDirLisView FOR oDirListView

Object oDirListView is a dbView
   Set Label to "List the directory"
   Set Size to 140 268
   Set Location to 6 6

   Object oMaskForm is a Form
      Set Label to "Mask:"
      Set Size to 13 226
      Set Location to 5 35
      Set Label_Col_Offset to 2
      Set Label_Justification_Mode to jMode_Right
   End_Object    // oMaskForm

   Object oDirList is a List
      Set Label to "Files:"
      Set Size to 102 226
      Set Location to 20 35
      Set Label_Col_Offset to 2
      Set Label_Justification_Mode to jMode_Right

      Function FindLastBackSlash String sMask Returns String
          Integer iPos
          String sDirSeparator sChar

          Move (Sysconf (SYSCONF_DIR_SEPARATOR)) To sDirSeparator

          Move (Length (sMask) - 1) To iPos
          Repeat
              Move (Mid (sMask, 1, iPos)) To sChar
              Decrement iPos
          Until (iPos <= 1 Or sChar = sDirSeparator)

          If (sChar = sDirSeparator) Begin
              Move (Left (sMask, iPos + 1)) To sMask
          End

          Function_Return sMask
      End_Function // FindLastBackSlash        

      Procedure GoToDirectory
          String sDirEntry sMask

          Get Value To sDirEntry
          Move (Mid (sDirEntry, Length (sDirEntry) - 2, 2)) To sDirEntry
          If (sDirEntry <> "..") Begin
              Get Value Of oMaskForm To sMask
              If (Right (sMask, 1) <> Sysconf (SYSCONF_DIR_SEPARATOR)) Begin
                  Move (sMask - Sysconf (SYSCONF_DIR_SEPARATOR)) To sMask
              End
              Move (sMask - sDirEntry) To sMask
              Set Value Of oMaskForm To sMask
              Send DoFillList
          End
          Else Begin
              Get Value Of oMaskForm To sMask
              Get FindLastBackSlash sMask To sMask
              Set Value Of oMaskForm To sMask
              Send DoFillList
          End            
      End_Procedure // GoToDirectory

      On_Key kEnter Send Default_Key

      Procedure Mouse_Click Integer iParam1 Integer iParam2
          Forward Send Mouse_Click iParam1 iParam2

          If (Message (Self, Current) <> Msg_None) Begin
              Send GoToDirectory
          End
      End_Procedure // Mouse_Click

      Procedure DoFillList
          String sDirMask sDirEntry
          Integer iChannel
          Boolean bOldState

          Get Dynamic_Update_State To bOldState
          Set Dynamic_Update_State To False

          Send Delete_Data

          Get Value Of oMaskForm To sDirMask
          Get Seq_New_Channel To iChannel
          If (iChannel >= DF_SEQ_CHANNEL_MIN And iChannel <= DF_SEQ_CHANNEL_MAX) Begin
              Direct_Input Channel iChannel ("DIR:" - sDirMask)
              While (Not (Seqeof))
                  Readln sDirEntry
                  If (Not (Seqeof)) Begin
                      If (Left (sDirEntry, 1) = '[') Begin
                          Send Add_Item Msg_GoToDirectory sDirEntry
                      End
                      Else Begin
                          Send Add_Item Msg_None sDirEntry
                      End
                  End
              End
              Close_Input Channel iChannel
              Send Seq_Release_Channel iChannel
          End

          Set Dynamic_Update_State To bOldState
      End_Procedure // DoFillList

      Procedure Entering
         Forward Send Entering

         Send DoFillList
      End_Procedure // Entering
   End_Object // oDirList
End_Object // oDirListView

Of Special Note

List-class objects automatically create their own scroll bar, and assign its location and colors to match itself. When the object is activated, deactivated, paged, rotated up or moved, the scrollbar is automatically manipulated by the List-class object. You may make the scrollbar invisible by setting the object's scroll_bar_visible_state to false.

Use of Item List for Initialization

This class is designed to allow the number of items to change based on the amount of data needed when the program is being executed. Normally, the items are added into the object with the add_item and/or insert_item messages. However, if there is an initial set of items to be used when the object is first created, an item list can be defined in this object. This does not preclude changing the content or number of items later in the program.

Shadowing

Shadowing refers to the process of making an object or an item unavailable for data entry. Usually the appearance of a shadowed object/item is changed in some way to indicate its unavailability. Two types of shadowing are supported: object shadowing and item shadowing.

This class supports both object and item shadowing. Accordingly, objects of this class will be shadowed whenever an ancestor object is shadowed, and its items can be shadowed individually or all together. The enabled_state and item_shadow_state properties are supported, as well as the entire public interface for shadowing.

Accelerator Keys

Name Message Sent
kscroll_back key kscroll_back
kscroll_forward key kscroll_forward

See Also

dbList