Display Pictures in a List

File: SAMPLES\SOLUTION\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.