Create Form And Properties

Now that we have a bunch of controls on the form, we have to jazz them up a bit. We do this by changing the Properties of the controls in the Properties window. Each control has a whole series of properties, most of which we won’t need right now. The ones we do need are:

Alignment = how text aligns in the control
BackColor = choose the color of the background
Caption = the text that will appear in the control
Font = choose the font type and size
ForeColor = choose the color of the text (foreground)

As with all Windows applications, you can select multiple controls with (Ctrl)+(Click) and change a property for all of them at once. For example, if all backgrounds are white, select all controls, change ForeColor to white and all of them are modified. Change your form to look like the one below. Note that you do not have to change the Caption for Label4, Label5 and Label6 and that you can’t change the color of the buttons. They insist on being what was called in the old days “IBM grey”. Don’t forget to save your project often as you go along!

If you Run the application at this point, you should see your Form appear, just the way you created it. However if you click on any of the controls, absolutely nothing happens! There are events that occur; the form opens, a button is clicked, etc. But, there is nothing that tells the form what to do when it sees an event. That is why we have to write code, also called script.

           

To switch between the Code window and the Form window, use the buttons just over the Project Explorer window (diagram on the left).
Once in the Code window, you have the option of seeing all the code for the Project or the code for one event at a time. Use the buttons in the lower left-hand corner (diagram on the right).
To select the object and the event you wish to code, use the two Listboxes at the top of the Code window. The one on the left for the object and the one on the right for the event. Start with General … Declarations and then Form … Load, etc.

At this point you might want to download the sample program and study it. In the following lessons we’ll add functionality to the exercice and we’ll explain what the code means. But for the moment, a good exercice would be to write part of the code and then try to figure out how to improve certain aspects of the program.

You can download the application here: FootScoreboard.zip

Now we can Run it and see something happen. When the Form loads, it will initialize the fields that we specified in the code.

Now code the Command1 button and Run it to see the result.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: