8. Working with Images and Text Strings : How You Can Work with Images : Palette Fields : How You Can Insert an Image into a Palette Field
 
Share this page                  
How You Can Insert an Image into a Palette Field
To insert a bitmap object programmatically into a palette field, use the AddBitmapItem method defined for the ChoiceList system class. You would follow these basic steps:
1. Declare a variable of type BitmapObject.
2. Load a DBHandle or FileHandle into the bitmap reference variable.
3. Insert the image into the palette field using the AddBitmapItem method.
4. Refresh the display using the UpdChoiceList method defined for the ChoiceField system class.
For example, the following statement from an initialize block adds a bitmap image from the v_video_graphics table to the first item in a palette field named vidchoices:
...
declare
   bo = BitmapObject;
enddeclare
begin
   bo.DBHandle = 'v_video_graphics:3';
   field(vidchoices).ValueList.
   AddBitmapItem
       (enumvalue=1, textvalue = 'comedy',
        bitmapvalue = bo);
...
To insert an image into each value of a palette field, declare an array of BitmapObject and load the appropriate handle into each row of the array.