Sunday 15 January 2012

How to add a image to a form in Ax 2009

Hi friends ,

   Today we are going to add a image to form below the grid to diplay the related image,
In form take a new group and add a window control to display the image.Add a button group and take a menu item button from it. The properties of menu item are as follows,
Property                           Value
Name                            CompanyImage
MenuItemType              Display
MenuItemName            CompanyImage
Text Item                       image
DataSource                  InventTable
In class declaration of your form declare a container and add a method on form of to load the images,
the code for form is as follows,

void loadImage()
    Image        img;
    CompanyImage companyImage;
    companyImage = CompanyImage::find(
         InventTable .TableId,
         InventTable .RecId);
    if (companyImage.Image)
        img = new Image();
Take a button under menuitem buton and name it as "save as"
to save the image which u have created  take a new method on form and write the following code

void saveImage()
    Image    img;
    Filename name;
    str      type;
    if (!imageContainer)
    img = new Image();
    type = '.'+strlwr(enum2value(img.saveType()));
    name = WinAPI::getSaveFileName(
    if (name)

And write a active method in datasource properties
 And in save button override the clicked method and write the code as following
By this a image is displayed by using this functionality
        By vivek chirumamilla

No comments:

Post a Comment