Presentation is loading. Please wait.

Presentation is loading. Please wait.

110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus.

Similar presentations


Presentation on theme: "110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus."— Presentation transcript:

1 110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus … and more Work with an example More on VB.NET IDE

2 110-C2 Have the user enter a line of text Allow the user to change the color of the text using radio buttons Include a picture on the form Allow the user to hide or show the picture using a checkbox Goal : A simple word processing application

3 110-C3 Sketch a textbox a group box a radio button a check box an image a button a label

4 110-C4 Displays an option that can be turned on or off (property checked true or false). When the user checks or unchecks the radio button the CheckedChange event is generated New Objects(1) Radio Button To group radio buttons together, draw a group box first. Then, bring the radio buttons in the group box. Within a group box, only one radio button can be selected by the user.

5 110-C5 Use Check Box controls in groups to display multiple choices New Objects(2) Check Box Displays an option that can be turned on or off. Several checkboxes can be selected by the user. When the user checks or un-checks a check box the CheckedChange event is generated

6 110-C6 Use the Picture Box control to display a graphic. The picture box control can display an image from many types of files (Use image property) (bitmap, icon, meta, jpeg, gif), To display text entered at the keyboard by the user. New Objects(3) Picture Box Textbox

7 110-C7 Text grpColor identifies the group box Name identifies the button Group box title Color Text radBlue Blue button title Setting up the form(1) Name group box radio button Name identifies the box Text chkShow Show box title Property Description Object Property setting check box

8 110-C8 Text txtMessage identifies the box Name identifies the image what is written in the box Nothing! (user writes in the box) Image picWord StrechImage location of the image file Setting up the form(2) Name Property Description Object Property setting text box Picture box SizeMode Visible C:\Windows\ True image fits the control image is visible

9 110-C9 Click on a checkbox or radio button? Yes Change the Color or Hide/Show the picture No The algorithm(1) Responding to the click on a checkbox or radio button: Change the textbox properties (Forecolor) or the Picture Box properties (visibility)

10 110-C10 Coding (1) Code to respond to a click on Red: Private Sub radRed_CheckedChanged (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radRed.CheckedChanged 'Change the color of txtMessage to Red ‘Color.Red is a color constant in the color ‘class txtMessage.ForeColor = Color.Red End Sub a comment starts with '

11 110-C11 Click on the clear button ? Yes Clear the text box No The algorithm(2) Responding to the click on the clear button: Change the textbox property, Text, to "" (=no text)

12 110-C12 Coding (2) Code to respond to a click on Clear: Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click 'Clear the content of txtMessage 'and set the focus back to the text box 'use With/End With to avoid typing ' txtMessage twice With txtMessage.Text = "".Focus() End With End Sub The cursor appears in the textbox, inviting the user to type some text "" means no text. In a program, text is always written between quotes

13 110-C13 Click on the exit button ? Yes End the program No The algorithm(3) Responding to the click on the exit button: use the instruction End or Me.Close() in the code

14 110-C14 Coding (3) Code to respond to a click on Exit: Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click 'End the program ‘We could use the instruction End or Me.Close() End Sub instruction to terminate an application

15 110-C15 Focus Ability to receive mouse clicks or keyboard input (object is highlighted, has a flashing cursor...) only one form or control at a time has the focus TabStop: if True, object can receive focus if False, object can't receive focus Tabindex: set the focus order of an object

16 110-C16 Access Keys To select a control on a form via the keyboard e.g. on our form Message, the Exit button can be accessed by typing Alt + x. To do so, type E&xit for the Text of btnExit Also, for a button : set the AcceptButton Property of form to the Button’s name button is activated with the Enter key button is activated with the Esc key set the CancelButton Property of form to the Button’s name


Download ppt "110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus."

Similar presentations


Ads by Google