Share via


How to: Add Pictures to Items in a List

You can display pictures next to items in lists.

To display pictures next to items in a list

  • Set the Picture property to a graphic file for the list box.

For more information, see Picture Property (Visual FoxPro) and Graphics Support in Visual FoxPro.

For example, suppose you populate a list box with files and want to display a different graphics file next to each file depending on whether the file is table, a program, or some other file type.

List box with pictures

FoxProCdriveExample screenshot

The following code uses the FOR ... ENDFOR command to

displays a different graphics file for each item in the list and appears in the Click event of this 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

For more information, see Click Event.

See Also

Tasks

How to: Use Check Boxes to Specify States

Concepts

Controls for Displaying Lists

Controls and Objects Created in Earlier Versions

Reference

Controls for Accepting Input

Other Resources

Using Controls