- Step 1 - Declare global variables in <yourform>.classdeclaration
public class FormRun extends ObjectRun
{
Imagelist imageList;
Image image;
}
- Step 2 - Create Image List in <yourForm>.init
public void init()
{
imageList = new ImageList(ImageList::smallIconWidth(), ImageList::smallIconHeight());
image = new Image();
image.loadResource(1030); // tick icon
imagelist.add(image);
image.loadResource(927); // info icon
imageList.add(image);
image.loadResource(928); // warning icon
imageList.add(image);
image.loadResource(929); // red x icon
imageList.add(image);
super();
}
- Step 3 - Create a window field on the grid
Load the image list to the window in <yourForm>.init after the super();
public void init()
{
imageList = new ImageList(ImageList::smallIconWidth(), ImageList::smallIconHeight());
image = new Image();
image.loadResource(1030);
imagelist.add(image);
image.loadResource(927);
imageList.add(image);
image.loadResource(928);
imageList.add(image);
image.loadResource(929);
imageList.add(image);
super();
<windowField>.imageList(imageList);
}
- Step 4 - Create method to set image on window field
The picture set is the data item in the array, not the icon number
public client server display int setIcon()
{
#define.TickIcon(0)
#define.InfoIcon(1)
#define.WarningIcon(2)
#define.StopIcon(3)
if(!InventTable::find(this.itemNumber))
{
return #StopIcon;
}
else if(this.qtyOnHand() <= 0)
{
return #WarningIcon;
}
return #TickIcon;
}
- Step 5 - Link window field to data
DataSource = <table in step 4>
DataMethod = <display method in step 4>
No comments:
Post a Comment