Tech Tip: Using Multiple Widgets on the same form.
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: May 25, 2012
When a widget is added to a form it is assigned a default variable name such as vDate for the Date Picker. To use multiple widgets on the same form the variable names must be changed so that each widget has a unique variable name. This can be done in the Properties List of the Widget.
However, this alone will not be enough. By default the Object Method of the widget will initialize the default variable. Since the variable name has been changed the new variable must be initialized. This can be done by editing the Object Method of the widget to initalize the new variable.
The sample below shows the line of code to be updated in the Object Method of a Date Picker widget to initalize the new variable name.
// Init the var itself // this can be done anywhere else in your code C_DATE(vDate1) //new date variable name |
Alternatively the variable can be initialized in the Forms On Load event.
The sample below shows two Date variables being initialized in the On Load event for a form with two Date Picker widgets.
Case of : (Form event=On Load) // Init both variables C_DATE(vDate1) //new date variable name C_DATE(vDate2) //new date variable name End case |
It does not matter where the variables are initialized as long as it is done before the widget is used.