This.View = 3 lcCursor = ALIAS() lnFldCount = AFIELDS( laFields, lcCursor ) lnIndex = 0 FOR lnCnt = 1 TO lnFldCount lnIndex = lnIndex + 1 DIMENSION This.aDisplayFields[ lnIndex, 2 ] This.aDisplayFields[ lnIndex, 1 ] = laFields[ lnCnt, 1 ] *** Now, if we have a caption available, use that for the header *** So check to see if the data source is in a dbc and retrieve the caption *** if it is, otherwise use the name of the field lcDbc = CURSORGETPROP( "Database", lcCursor ) IF NOT EMPTY( lcDbc ) *** Make sure it is the current database SET DATABASE TO ( lcDBC ) *** Get the caption for this field lcCaption = DBGETPROP( lcCursor + '.' + laFields[ lnCnt, 1 ], 'Field', 'Caption' ) IF EMPTY( lcCaption ) lcCaption = laFields[ lnCnt, 1 ] ENDIF This.aDisplayFields[ lnIndex, 2 ] = lcCaption ELSE This.aDisplayFields[ lnIndex, 2 ] = laFields[ lnCnt, 1 ] ENDIF ENDFOR *** Must Add the Column Headers for all the we are going to display Items in the cursor lnColumnCount = ALEN( This.aDisplayFields, 1 ) WITH This.ColumnHeaders FOR lnItem = 1 TO ALEN( This.aDisplayFields, 1 ) *** Calculate the width for this column lnHdrWidth = ( LEN( This.aDisplayFields[ lnItem, 2 ] ) + 16 ) * FONTMETRIC( 6, 'Arial', 9 ) lnColWidth = LEN( TRANSFORM( EVALUATE( lcCursor + '. ' + This.aDisplayFields[ lnItem, 1 ] ) ) ) * FONTMETRIC( 6, 'Arial', 9 ) IF lnColWidth < lnHdrWidth lnColWidth = lnHdrWidth ENDIF .Add( , , This.aDisplayFields[ lnItem, 2 ], lnColWidth, lvwColumnLeft ) ENDFOR ENDWITH *** Now populate all the rows WITH This.ListItems *** Add the ListItem for this Record *** And set the ListItem's Key to the Name of the cursor and PK field of the data source loItem = .Add( , lcCursor + '_' + ALLTRIM( TRANSFORM( EVALUATE( lcCursor + '.' + This.cPkField ) ) ), ; ALLTRIM( TRANSFORM( EVALUATE( lcCursor + '.' + This.aDisplayFields[ 1, 1 ] ) ) ) ) *** Use fields 2 - n to populate the list's SubItems WITH loItem FOR lnItem = 2 TO ALEN( This.aDisplayFields, 1 ) .SubItems( lnItem - 1 ) = ALLTRIM( TRANSFORM( EVALUATE( lcCursor + '.' + This.aDisplayFields[ lnItem, 1 ] ) ) ) ENDFOR ENDWITH ENDWITHHTH