jeudi 30 décembre 2010

How to get and edit controls in a forms from X++

There are two ways to do it, as usual there is a hard and an easy way.

1- Declare the Control:
The very will know way is the easy way, that you set the control as "AutoDeclaration" to YES , but unfortunately this way has a serious drawback.

image











The "AutoDeclaration" makes the system slower for couple of reasons.

2- Define the control programmatically:
This is the hard way, but it performs better, since it does apply only one call.

Create the method in my case it is an event overwritten method, and I want to access "VendPurchOrderJour_InvoiceAccount"

image











Here is the Code.
void clicked()
{
FormDateControl         dt;        //Form Control Type
FormStaticTextControl   st;         //Form Control Type
;
super();
//Where “VendPurchOrderJour_InvoiceAccount” is the Control Name
dt = element.design().control(control::VendPurchOrderJour_InvoiceAccount);
st = element.design().control(control::MyStaticText);
st.text(dt.valueStr());
}

About the Form Control Type, here the list of all form types *:

Form control type
Class
ActiveX
Animate
Button
ButtonGroup
CheckBox
ComboBox
CommandButton
DateEdit
Grid
Group
GuidEdit
HTML
Int64Edit
IntEdit
ListBox
ListView
MenuItemButton
MenuButton
Progress
RadioButton
RealEdit
StaticText
StringEdit
Tab
TabPage
FormTabPageControl
Table
TimeEdit
Tree
Window

Happy Daxing !

Aucun commentaire:

Enregistrer un commentaire