Building Windows Form Application LESSON 9: Prepared by: Ms. Liezeth O. Mesa
The C# Windows Form Application Environment In creating a Windows-based program, you will design and layout different controls on the user interface. The windows form is an important part in developing any windows-based application because it is where you design the layout of the application.
Four Steps in Creating WFA Create the interface. Set the properties for the controls. Write the code. Test the code.
To add controls on the form, do either the following: Double-click the control in the toolbox. This places the control with a default height and width in the center form. Click once on the form in the toolbox, then move your mouse to the position on the form where you want to begin drawing the control.
To add code in control, do these: Double-click the control . The code editor will appear. Type in the code needed for the control.
LET’S work it out! Activity 9.1: Create your first windows forms application Page 118 - 120
What is Control? Controls, also called objects such as a button and a textbox, can perform an action when clicked by the user.
Here are some C# controls CONTROL NAME FUNCTION SYMBOL LABEL Displays text or message for the use of other controls. It can only show output an output and cannot accept users input. BUTTON Executes a specific action and performs commands written in the code editor. TEXTBOX Displays text same with the label but unlike the label, this will allow input from the users.
Here are some C# controls CONTROL NAME FUNCTION SYMBOL LISTBOX Show a list of choices that is presented vertically in a single column CHECKBOX Used for turning on or off a particular feature of a program COMBOBOX Show choices through a drop down menu
Here are some C# controls CONTROL NAME FUNCTION SYMBOL PICTUREBOX Creates a box that displays pictures with a fixed size. It does not allow resizing of pictures.
Naming Convention In naming a control in C#, the following are also observed and followed: It should not start with number. The underscore symbol can only be used. It must not include a space or a blank.
PREFIX OBJECT TYPE cbo combo box chk checkbox cmd button frm form lbl label lst list box mnu menu opt option button pic picture box shp shape txt textbox NOTE: we use the following Prefix in changing the properties (NAME) of each control. Example: txtNum1 as name/code
The button and textbox control To understand more about the Button and Textbox controls, here is a sample program called my calculator. Let’s try Activity 9.2 Page 123-127
THANK YOU! ;)
Naming Convention In addition, the following are recommended: Start each word with capital letters. For example: FirstName and MyFirstName . Use verb for function and method names. For Example: AddNewRecord or CloseMenu . Use prefix “I”, in declaring the name for interface, followed by a noun or a noun phrase.