Display Pictures in a List Sample

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

This sample illustrates how you can enhance 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.

 CopyCode imageCopy Code
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
      * Remote view
      thisform.lstDatabase.Picture[m.i] = m.cRViewBMP

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

© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic