1 / 7

GUI Programming in Visual Studio .NET

GUI Programming in Visual Studio .NET. Chapter 2 Tariq Aziz and Kevin Jones. Properties of a GUI Object.

josephcking
Télécharger la présentation

GUI Programming in Visual Studio .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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. CA 121 Intro to Programming Tariq Aziz and Kevin Jones

  3. 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” CA 121 Intro to Programming Tariq Aziz and Kevin Jones

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

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

  6. 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. CA 121 Intro to Programming Tariq Aziz and Kevin Jones

  7. Build the Lucky Seven Program 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. CA 121 Intro to Programming Tariq Aziz and Kevin Jones

More Related