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

GUI Programming in Visual Studio .NET

  • Upload
    cale

  • View
    49

  • Download
    3

Embed Size (px)

DESCRIPTION

GUI Programming in Visual Studio .NET. Chapter 3 Tariq Aziz and Kevin Jones. Overview. Chapter 3 is about using Toolbox controls in Visual Studio .NET. TextBox Button CheckBox RadioButton ListBox ComboBox DateTimePicker LinkLabel. TextBox. - PowerPoint PPT Presentation

Citation preview

Page 1: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

GUI Programmingin Visual Studio .NET

Chapter 3

Tariq Aziz and Kevin Jones

Page 2: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

OverviewChapter 3 is about using Toolbox controls in Visual

Studio .NET.

• TextBox

• Button

• CheckBox

• RadioButton

• ListBox

• ComboBox

• DateTimePicker

• LinkLabel

Page 3: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

TextBoxThe TextBox control provides a way for your program to get

text input from the user. He simply types text in the textbox.

The text entered by the user is stored in the Text property of the Textbox. You can access it as follows

TextBox1.Text

Page 4: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

Example – Ch. 1

This event procedure contains code that willbe executed when the user clicks the Answerbutton at run-time.

Page 5: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

ButtonThe Button control provides a way for your program to get

click input from the user. He simply clicks a button when he wants to initiate some response from the program.

The text displayed inside the button is stored in the Text property of the Button, which is usually defined by the programmer through the Properties window at design time.

When the user clicks the button at runtime, the corresponding event procedure is invoked, which will perform the actions associated with the button. By default, the name of the event procedure is the concatenation of the name of the button with the string “_Click”, e.g. Button1_Click() for Button1.

Page 6: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

CheckBoxThe CheckBox control provides a way for your program to get

on/off input from the user. The checkbox is a toggle switch; the user clicks in the checkbox to turn it off or on.

A group of checkboxes allows the user to select zero or more choices from the group. Selection of one checkbox of a group is independent of the other checkboxes (see radio buttons for contrast).

The CheckedState property stores the on/off state of the checkbox. If the user has checked the checkbox, CheckedState = True; otherwise, it is False. You can access the CheckedState property as follows:

CheckBox1.CheckedState

Page 7: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

RadioButtonThe RadioButton control provides a way for your program to

get on/off input from the user. The radio button is a toggle switch; the user clicks in the radio button to turn it off or on.

A group of radio buttons allows the user to select exactly one choice from the group. The difference between the behavior of a radio button and a checkbox is that when the user clicks a radio button, all other radio buttons in the same group are turned off.

The CheckedState property stores the on/off state of the radio button. If the user has selected the radio button, CheckedState = True; otherwise, it is False. You can access the CheckedState property as follows:

RadioButton1.CheckedState

Page 8: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

ListBoxThe ListBox control provides a way for your program to allow

the user to choose an item from a list. He simply clicks on the item in the ListBox to select it.

All items in the list box appear on the form. The SelectedIndex property of the list box stores the index of the list item that was selected by the user.

ListBox1.SelectedIndex

SelectedIndex counting starts at 0. For example, say we have a list of five items: US Dollar, Saudi Riyal, British Pound, Japanese Yen, and Euro. Each item would have indices 0, 1, 2, 3, and 4, respectively. For example, if the user selects British Pound, the SelectedIndex property of the ListBox would be set to 2.

Page 9: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

ComboBoxThe ComboBox control provides a way for the user to select

an item from a list. It’s very similar to a ListBox, except that the whole list is not displayed directly on the form. Instead, the list is only displayed when the user clicks the drop-down arrow. Once the user makes his selection, the selection is displayed in the combo box on the form. For this reason, the combo box is also called a drop-down listbox.

The combo box also has a SelectedIndex property, which stores the index of the selected item.

Page 10: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

DateTimePickerThe TextBox control provides a way for your program to get

text input from the user. He simply types text in the textbox.

The text entered by the user is stored in the Text property of the Textbox. You can access it as follows

TextBox1.Text

Page 11: GUI Programming in Visual Studio .NET

CA 121 Intro to ProgrammingTariq Aziz and Kevin Jones

LinkLabelThe TextBox control provides a way for your program to get

text input from the user. He simply types text in the textbox.

The text entered by the user is stored in the Text property of the Textbox. You can access it as follows

TextBox1.Text