views:

175

answers:

1

I am attempting to manually populate an image icon into a window nested in a grid.

In the run event, the fields don't appear to have values yet. The string control always returns an empty value. Is there a better place for this code? In .NET, I'd use a databound event. Is there an equivalent in AX?

void run()
{
    FormStringControl s = element.control(control::ABC_Icons_FileName);
    FormWindowControl w = element.control(control::ABC_Window);
    ;
    w.imageName(s.valueStr());
    super();
}

Thanks

+1  A: 

If I correctly understand your task you want to display image in each line of grid? Then:

  1. Create ImageList in form.init():

    imageList = new ImageList(ImageList::smallIconWidth(), ImageList::smallIconHeight();
    Image image = new Image();
    ;
    image.loadImage(filename)
    imageList.add(image);
    // ...
    image.loadImage(filename-n)
    imageList.add(image);
    

    ImageList must be declared in ClassDEclaration section.

  2. Set AutoDaclaration property of Window field in the Grid to "Yes".

  3. Set ImageList for the window field in the method init() of form:

    MyWindow.imageList(imageList);
    
  4. On the Table which you are using on the form create the display method. Something like this:

    display int status()
    {
       if(this.amount > 10)
           return 5;  // 5th image from image list
       else
           return 6;
    }
    
    1. Set properties DataSource and DataMethod for your window control:

      DataSource = DataMethod = status

Look at form ReqTransPo if you need more example.

demas