We can add lots of FormControls dynamically on form design. In
this Post, I am showing you to add some formControls runtime or click by Button.
So if you want to add these control at runtime you have to write all below code
in “init()” on form Methods and if you want to add these control clicking by
button then you have to override “click()” on created button methods. And I'm going to use second way (click by Button) in this post for every control. For this
first we should create a form with designs according to figure 1.
Figure 1 – Create Form
Design
1. Create Group :-
void clicked()
{
FormBuildDesign formBuildDesign = form.design();
FormBuildGroupControl formBuildGroupControl;
FormGroupControl formGroupControl ;
;
formGroupControl =
OldGroup.addControl(FormControlType::Group,'NewGroup');
formGroupControl.caption("Description");
FormBuildGroupControl =
formBuildDesign.control(OldGroup.id());
}
Figure 2 – Add GroupControl
2. Create ComboBox :-
void clicked()
{
FormBuildDesign formBuildDesign = form.design();
FormBuildComboBoxControl formBuildComboBoxControl;
FormComboBoxControl formComboBoxControl;
;
formComboBoxControl =
OldGroup.addControl(FormControlType::ComboBox,'ComboBox');
formComboBoxControl.label("ComboBox");
formComboBoxControl.enumType(118); // 118 is Id for ItemType enum
formBuildComboBoxControl =
formBuildDesign.control(OldGroup.id());
super();
}
Figure 3 – Add ComboBox
3. Create CheckBox:-
void clicked()
{
FormBuildDesign formBuildDesign = form.design();
FormBuildCheckBoxControl formBuildCheckBoxControl;
FormCheckBoxControl formCheckBoxControl;
;
formCheckBoxControl =
OldGroup.addControl(FormControlType::CheckBox,'CheckBox');
formCheckBoxControl.label("CheckBox");
formBuildCheckBoxControl =
formBuildDesign.control(OldGroup.id());
super();
}
Figure 4 – Add CheckBox
4. Create TabPage:-
void clicked()
{
FormBuildDesign formBuildDesign = form.design();
FormBuildTabPageControl formBuildTabPageControl;
FormTabPageControl formTabPageControl;
;
formTabPageControl =
tab.addControl(FormControlType::TabPage,'TabPage');
//tab
is already create tab set auto declaration - Yes
formTabPageControl.caption("Details");
formTabPageControl.width(500);
formTabPageControl.height(100);
formBuildTabPageControl =
formBuildDesign.control(tab.id());
super();
}
Figure 5 – Add TabPage
5. Create Grid:-
void clicked()
{
FormBuildDesign formBuildDesign = form.design();
FormBuildGridControl formBuildGridControl;
FormGridControl formGridControl;
;
formGridControl = OldGroup.addControl(FormControlType::Grid,'Grid');
formGridControl.width(500);
formGridControl.height(100);
formBuildGridControl =
formBuildDesign.control(OldGroup.id());
super();
}
Figure 6 – Add GridControl
6. Create StringEdit in Grid:-
void clicked()
{
FormBuildDesign formBuildDesign = form.design();
FormBuildStringControl formBuildStringControl;
FormStringControl formStringControl;
;
formStringControl =
Grid.addControl(FormControlType::String,'StringEdit');
formStringControl.extendedDataType(99);
formBuildStringControl =
formBuildDesign.control(TabPage1.id());
super();
}
Figure 7 – Add StringEditControl on Grid with
CustomerAccount EDT
No comments:
Post a Comment