Control Arrays | ||
Using arrays of controls or custom controls provides a very powerful means of dealing with certain kinds of data manipulation. In this example we will be using this technique to make a simple quiz program. | ||
Step 1- Creating a Custom Control | ||
Add a new Class to your project. Call it "answerField" and enter EditField as its Super. To answerField add two properties: result as boolean and rightAnswer as string. | ||
![]() | ||
NOTE: When adding the "rightAnswer" property be sure to check the Show in Properties Window checkbox. We will see why shortly. | ||
![]() | ||
Now we will add some code to answerField. Put the following code in the TextChange event of answerField. We will see a bit further on how this code utilizes the two properties (result as boolean, and rightAnswer as string) to keep track of right and wrong answers. | ||
![]() | ||
Step 2- Creating the Control Array | ||
To Window1 add a staticText control for the first question. Also add an editField for the answer. In the properties window set the super of the editField to "answerField" and name it "responseField. | ||
![]() | ||