How Do I Dynamically Set the Option List of a Choice Control? (Magic xpa 3.x)
While you can hard-code the choices for an option list, you can also set them dynamically, using expressions. In this example, we dynamically created the radio button from four user entries.
To create a dynamic choice control:
-
Create a virtual that will hold the choice. In this example, it is variable P.
-
Drag the Radio Button from the Toolbox (or whatever choice control you are using), and drop it on your form.
-
Select your virtual for the Data property. In this example, it is variable P.
-
Create an expression for your Items List property, that will evaluate into the comma-delimited string you need at runtime.
-
Create an expression for your Display List property, that will evaluate into the comma-delimited string you need at runtime. In our example, we made it the same as the Items list.
Optionally, you can also enter some data string in the Display list. This value will show up in the Studio, and might make it easier to understand the form for the programmer. In our example we used “x,y,z”.
Now, the choice control values will be determined at runtime, according to the values in the expression.
The Online and Rich Client Samples projects (program HG20 and RHG20)