Display Pictures in a List

File: ...\Samples\Solution\Controls\Lists\Piclist.scx

This sample illustrates how you can spice up your list boxes by adding picture graphics beside the individual text items. In this sample, you can pick any database (.dbc) file, and the list box will show different images beside the names of tables, local views and remote views.

The following code from cmdDatabase.Click enumerates through a .dbc and selectively adds pictures to list items using the Picture property. The Picture property relies on an index setting to determine which list item to affect.

FOR i = (m.nTblCount+1) TO thisform.lstDatabase.ListCount
IF DBGETPROP(ALLTRIM(thisform.lstDatabase.List[m.i]),; "view","sourcetype") = 1  
       *Local view
      thisform.lstDatabase.Picture[m.i] = m.cLViewBMP
   ELSE
      * Remote view
      thisform.lstDatabase.Picture[m.i] = m.cRViewBMP
   ENDIF
ENDFOR

Note   You need to ensure that the images used are sized correctly to fit within the space of a single list box item, which differs with the FontSize of the list.

See Also

Add Items Interactively to a List Box | Display Pictures in an Image Control | Solutions Samples