次の方法で共有


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.

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

Tasks

Add Items Interactively to a List Box Sample

Display Multiple Columns in a List Box Sample

Fill a List with Values from Different Sources Sample

Move Items Between List Boxes Sample

Multiselect Items in a List Box Sample

Open Multiple Files Interactively Sample

Sort List Box Items Sample

Treeview/Listbox Drag and Drop Sample

Other Resources

Controls Solution Samples