Freigeben über


Adding Pictures to Items in a List

You can set the Picture property of the list to the graphic file you want displayed next to the items in the list. For details on valid file types, see Graphic Support in Visual FoxPro

For example, you could have a list box populated with files. You might want to have a different bitmap next to the file if it is a table, a program, or some other file type.

List box with pictures

The following code is associated with the Click event of the list box:

FOR iItem = 5 TO THIS.ListCount      && files start at the 5th item
   cExtension = UPPER(RIGHT(THIS.List(iItem),3))
   DO CASE
      CASE cExtension = "DBF"
         THIS.Picture(iItem) = "tables.bmp"
      CASE cExtension = "BMP"
         THIS.Picture(iItem) = "other.bmp"
      CASE cExtension = "PRG"
         THIS.Picture(iItem) = "programs.bmp"
      CASE cExtension = "SCX"
         THIS.Picture(iItem) = "form.bmp"
      OTHERWISE 
         THIS.Picture(iItem) = IIF("]" $ cExtension, ;
            "", "textfile.bmp")
   ENDCASE
ENDFOR

See Also

Displaying Child Records in a List | Using Check Boxes | Accepting Input That Cannot Be Predetermined | Using Controls | Controls and Objects