Presentation is loading. Please wait.

Presentation is loading. Please wait.

CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 2 Tariq Aziz and Kevin Jones.

Similar presentations


Presentation on theme: "CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 2 Tariq Aziz and Kevin Jones."— Presentation transcript:

1 CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 2 Tariq Aziz and Kevin Jones

2 CA 121 Intro to Programming Tariq Aziz and Kevin Jones Properties of a GUI Object A GUI Object may have many properties. For example, a button object has a name, size, and location. The text property holds the string that is displayed in the button on the form. Suppose we want two buttons on our form: an OK button and a Quit button. After dragging two buttons from the toolbox to our form, we need to set the text property of each button, so that the following is true: Button1.Text = “OK” Button2.Text = “Quit” Notice that we access the property of an object using dot notation; the name of the object comes first, then a dot, then the name of the property.

3 CA 121 Intro to Programming Tariq Aziz and Kevin Jones Setting GUI Object Properties We set the property of an object at design time using the Properties window. First, select the GUI object on your form (you’ll see selection handles appear around the object). The Properties window displays the properties of the currently selected object in the Windows Forms Design window. Simply scroll through the properties to find the one you want, then click on the value and change it. Note that setting the properties at design time determines the initial value of the properties at run-time. We may also change the values of properties at run-time by executing assignment statements, such as Button1.Text = “Push here”

4 CA 121 Intro to Programming Tariq Aziz and Kevin Jones Example – Ch. 1 This event procedure contains code that will be executed when the user clicks the Answer button at run-time.

5 CA 121 Intro to Programming Tariq Aziz and Kevin Jones How To Go Back to Form Click this tab to go back to the form design window.

6 CA 121 Intro to Programming Tariq Aziz and Kevin Jones Lucky Seven program (Ch. 2) The Lucky Seven program from chapter 2 is a simple application that gives you practice in basic GUI programming. The program allows the user to click the Spin button, each time displaying three random numbers between 0 and 9. The user “wins” if any of the three numbers happens to be “7”, and he loses otherwise. First we’ll setup the user interface, then we’ll define the code behind the Spin button.

7 CA 121 Intro to Programming Tariq Aziz and Kevin Jones To build (or compile) the program, select Build Solution from the Build menu. To run the program, select Start from the Debug menu, or simply click the Start (Play) button on the standard toolbar. Note: You must login as “student” (password = “computer”) to use this feature. Build the Lucky Seven Program


Download ppt "CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 2 Tariq Aziz and Kevin Jones."

Similar presentations


Ads by Google