Tuesday, 25 March 2014

Show (store/retrieve) Image on grid manually in ax 2012

Step 1 : Create a table and take Container type field  and extend it with Bitmap edt.
Image
Step 2: Create a Form  and drag & drop your field on that form Grid.
Capture2
Step 3: Now go to  window control > Methods > Override method > douseDblClick
Capture3
Now put the below code in these method
public int mouseDblClick(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
{
int ret;
str imageFilePathName;
container imageContainer;
FilenameFilter filter = ['Image Files','*.bmp; *.jpg; *.gif; *.jpg'];
BinData bindata = new BinData();
str extension, path, nameOfFile;
ret = super(_x, _y, _button, _Ctrl, _Shift);
imageFilePathName = WinAPI::getOpenFileName(element.hWnd(),filter,”,”,”,”);
if (imageFilePathname && WinAPI::fileExists(imageFilePathName))
{
[path, nameOfFile, extension] = fileNameSplit(imageFilePathName);
if (extension == ‘.bmp’ ||
extension == ‘.jpg’ ||
extension == ‘.gif’ ||
extension == ‘.jpeg’)
{
binData.loadFile(imageFilePathName);
imageContainer = binData.getData();
ImageTable.Image = imageContainer; //Here ImageTable is your table name
}
}
ImageTable_ds.research(); // ImageTable_ds is your datasource name.
return ret;
}
Save all and open form ImageTable.
Capture4
Step 4 : Double Click on field and select image. you will see your form like these.
Capture5
You can do the same thing with button too.
I used Change for the same. write your code on Click method of button.
Thanks.

No comments:

Post a Comment