2009-12-03 83 views
0

我試圖手動將圖像圖標填充到嵌套在網格中的窗口中。Axapta:表單生命週期問題

在運行事件中,字段看起來沒有數值。字符串控件總是返回一個空值。這個代碼有更好的地方嗎?在.NET中,我會使用一個數據綁定事件。 AX中是否有等價物?

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

感謝

回答

1

如果我正確理解你的任務要在每個網格線顯示圖像?然後:

  1. 創建form.init的ImageList():

    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必須ClassDEclaration段裏聲明。

  2. 將網格中的Window域的AutoDaclaration屬性設置爲「Yes」。

  3. 在形式的方法的init()的窗口字段中設置的ImageList:

    MyWindow.imageList(imageList); 
    
  4. 在其上所使用的窗體上創建的顯示方法的表。事情是這樣的:

    display int status() 
    { 
        if(this.amount > 10) 
         return 5; // 5th image from image list 
        else 
         return 6; 
    } 
    
  5. 設置屬性DataSource和DataMethod爲您的窗口控制:

    數據源= DataMethod =狀態

如果您需要更多示例,請查看錶單ReqTransPo。