如何使用代码中的按钮复制对话框中输入的文本?

时间:2015-06-15 13:32:06

标签: dialog copy-paste axapta x++ dynamics-ax-2012

我想在点击按钮后从代码中复制clipboard DialogBox 中的文字。

我需要在对话框中输入一个带有ctrl + c函数的按钮。

我的对话

有此代码
Dialog      dialog;
DialogField dialogField;
str string;
;
dialog = new Dialog("My personal dialog");
dialogField= dialog.addFieldvalue(extendedTypeStr(String30), string, "insert the text to be copied");

// ctrl + c button
//I need a button  with the function to copy the text entered
dialog.run();
if (dialog.closedOk())
{
}
}

感谢您的帮助,

享受!

1 个答案:

答案 0 :(得分:2)

Check the TextBuffer.fromClipboard method.

Example use:

TextBuffer txtb = new textBuffer(); 
#define.ExampleFile(@"c:\test.txt") 
#define.ExampleOpenMode("w") 

// Set code access permission to help protect the use of TextBuffer.tofile 
new FileIoPermission(#ExampleFile, #ExampleOpenMode).assert(); 

if ( txtb.fromClipboard() ) 
{ 
    // Got text from clipboard - save it to file 
    txtb.toFile(#ExampleFile); 
} 

// Close the code access permission scope. 
CodeAccessPermission::revertAssert(); 

It should be easy to adapt to a dialog.