Programming In Visual Basic.NET

Slides:



Advertisements
Similar presentations
Chapter 3.1 Controls Programming In Visual Basic.NET.
Advertisements

Chapter 2 More Controls Programming In Visual Basic.NET.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Chapter 2 –Visual Basic, Controls, and Events
Introducing More Controls Text boxCheck box Option button Command button frame image.
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
Chapter 2 More Controls Programming In Visual Basic.NET.
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
Chapter 2 User Interface Design Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Chapter 2 –Visual Basic, Controls, and Events
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Visual Basic Chapter 1 Mr. Wangler.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Chapter 2 User Interface Design Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
IE 411/511: Visual Programming for Industrial Applications
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 21 Creating Applications with Visual Basic.NET Chapter 2.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
Chapter 2 - More Controls More controls – Text boxes - used for user input – Frames - containers to group items – check boxes - user select an option -
CIS 338: VB.NET Components Dr. Ralph D. Westfall April, 2011.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Graphical User Interfaces 2 Tonga Institute of Higher Education.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Chapter Two Designing Applications Programming with Microsoft Visual Basic th Edition.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
2-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Chapter 2 P. 1 Introducing more controls (on the Toolbox) (Fig. 2.1) - Text box - Frame - Option button - Check box - Image Example P. 44 Figure 2.2 Message.
More Controls and Their Properties Part 4 dbg --- TextBox, CheckBox, RadioButton, GroupBox, ToolTips,
More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 2 User Interface Design.
2-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 2 User Interface Design.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
COMPUTER PROGRAMMING I 3.02 Apply Properties Associated with the Controls.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
MsgBox, Input Box Functions Check boxes, radio button MsgBox, Input Box Functions Lab 3 3 Ismail M. Romi: PPU- IT Dept.
Chapter 2 More Controls Programming In C Shap. © Controls in the Toolbox.
Graphical User Interface Concepts - Part 1 Session 08 Mata kuliah: M0874 – Programming II Tahun: 2010.
3.02 APPLY PROPERTIES ASSOCIATED WITH THE CONTROLS Computer Programming I.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Visual Basic.NET Windows Programming
Microsoft Visual Basic 2005: Reloaded Second Edition
Microsoft Access 2007 – Level 2
Chapter 1: An Introduction to Visual Basic 2015
IS 350 Course Introduction
Chapter 2 – Introduction to the Visual Studio .NET IDE
Variables and Arithmetic Operations
How to design a Windows Forms application
Chapter 3 Fundamentals of Programming in Visual Basic 3
Visual programming Chapter 3: GUI (Graphical User Interface) Part I
Chapter 2 Visual Basic Interface
Variables and Arithmetic Operations
Visual Basic.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Visual Basic Objects Controls
Visual Basic Objects Controls
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Building an Application in the Visual Basic .NET Environment
Visual Studio.
Brief description on how to navigate within this presentation (ppt)
Visual C# - GUI and controls - 1
Chapter 2 User Interface Design
Presentation transcript:

Programming In Visual Basic.NET Chapter 3.1 Controls Programming In Visual Basic.NET

Controls in the Toolbox Those controls that we will use in this class.

The Name Property How the programmer refers to a control in code Name must begin with a letter Must be less than 215 characters long May include numbers and the underscore Use appropriate 3 character naming prefix

Control Name Prefixes

Text Box (txt) Used for user input/data entry Text Property What is displayed in text box What user entered in text box TextAlign Property Controls alignment of text in the Text Box Change Event 7

TextBox Control – Properties BorderStyle - defines the border surrounding the text box ForeColor, BackColor - defines the text color and background color respectively Enabled - controls whether the text box can get focus and will respond to events Locked - controls whether user can change the text appearing in the text box MultiLine - controls whether text will appear on multiple lines MaxLength - defines the maximum number of characters that the user can enter into the text box

TextBox Control – Properties Name - defines name used to reference control instance with code Again, use a standard prefix of "txt" ScrollBars - defines whether vertical or horizontal scroll bars appear in text box Text - contains the text appearing in text box TextAlign - justifies text within the visible region of the control instance X, Y, Height, Width properties define the position and size of the control instance

TextBox - Methods and Events Focus method sets input focus to a text box Enter event fires when text box gets focus Leave event fires when text box loses focus TextChanged event fires when the the textual contents change at run time The event fires for each character typed

Button (btn) Used to run/activate an Event Procedure Click event Properties Text – Change the text property to display text to user Image – change image to use a graphic button Forecolor – changes the color of the text displayed Backcolor – changes the color of the button 5

Label (lbl) Used for Cannot by modified by user Output on a form Identification of objects Directions/Information Cannot by modified by user 6

Label Properties Text – used to display text or instructions to the user Font – change font size, color, appearance Image – use images to draw attention Autosize – adjust the label object to text entered into the text property textAlign – aligns the text displayed on the object

Group Box (grp) Used as containers for other controls such as radio buttons and check boxes Improves readability of form Text Property What is displayed on the top edge of the group box Splits the form object into separate planes allows several groups of radio buttons on one form. 7

Group box (grp) Group boxes must be added to the form before other objects are added to them. You can not drag checkboxes or radio buttons from the form to the group box The group box must have the focus of the cursor before you draw your other objects inside them Editing handles must be visible

Check Box (chk) Used for user input/data entry Allows the user to select or deselect 1 or more in any group Checked Property Checked = True Unchecked = False CheckChanged Event – default event 10

Radio Button (rdo) Used for user input/data entry Allows the user to select only 1 in any group First create a group and then create each radio button inside the group Checked Property Checked = True Unchecked = False CheckChanged Event – default event 9

Picture Box (pic) Displays/contains a picture/graphic Image Property Complete path and filename of graphic .bmp, .gif (including animated), .jpg, .png, .ico, .emf, .wmf SizeMode Property StretchImage causes graphic to be resized to match the size of the control Visible Property 11

Other Properties BorderStyle Property –None, FixedSingle, Fixed3D Forecolor – changes the color of text inside object Backcolor – changes the color of object Textalign – aligns text property Enable true (user can activate the object), false (object us not available to user) Visible True (object appears on form) False (object is hidden at run time) TabIndex – set the order of the focus for controls on the form 14

Properties and Methods Properties can be set at design time in the property box Or they be changed during program execution by statements in your code txtHours.Text = "“ ‘ clears the content Methods are action performed on objects txtHours.focus

Selecting Multiple Controls SHIFT-Click or CTRL-Click to select/deselect multiple controls Use the mouse to drag a selection box around multiple controls To deselect all selected controls click elsewhere on the form 15

Selecting Multiple Controls (cont.) Start here Drag to here Using mouse to drag a selection box around multiple controls Multiple selected controls, observe selection handles.

What Can be Done with Multiple Selected Controls? Use Format Menu or Layout Toolbar to Align them to each other Make same size Modify the spacing between them Move them as a group Set their common properties

Designing the User Interface To the user the Interface should be Easy to understand Familiar Comfortable Organized Sans Serif Fonts are best, not boldface or large Color Neutral Overall Keyboard Accessible

Keyboard Access Keys Also referred to as Hot Keys Underlined Letter User presses ALT + underlined letter Use Windows-Standard Keys Defined using Text Property Text=&OK Text=E&xit 17

Default & Cancel Buttons Default Button Identified visually on Form by its darker outline Responds to ENTER key Form's AcceptButton Property Cancel Button Responds to ESC key Form's CancelButton Property

Focus One control on a Form always has the Focus Not all control types can receive the focus TabStop Property (applicable only for controls that are capable of receiving the focus) Designates whether a control is allowed to receive the focus; True or False

Tab Order User should be able to use TAB key to move the focus through a form in an organized manner; top to bottom, left to right TabIndex Property Number in tab sequence 0 for first control to receive the focus when the form loads In form’s graphic view – Use View Menu, Tab Order to set 18

Setting TabIndex Property View menu, TabOrder Click on each control in sequence to set TabIndex property of controls automatically

Form's Screen Location StartPosition Property Manual CenterScreen WindowsDefaultLocation WindowsDefaultBounds CenterParent

ToolTips Small label that is displayed when user places pointer on a control and pauses Usually used with Command Buttons Steps for creating ToolTips Add a ToolTip Control to Form Appears in the Component Tray, pane at bottom of Form Designer where nondisplay controls are shown Set ToolTip on ToolTip1 Property of each control to the text of tip 19

ToolTip Control Component Tray

Clearing Text Boxes & Labels Set Text Property equal to the Empty String Empty String is 2 quotation marks with no space between them ("") Use the Clear Method of a Text Box txtName.Text = "" lblMessage.Text = "" txtCourse.Clear( ) 20

Resetting the Focus Places the Insertion Point in a Text Box Use the Focus Method txtName.Focus( ) 21

Checked Property of Check Boxes and Radio Buttons Selects/Deselects Check Box or Radio Button Set Checked Property True = Checked, selected False = Unchecked, deselected radRed.Checked = True chkBold.Checked = False 22

VB Color Constants ForeColor and BackColor Properties Use VB Color Constants from the Color Class View complete list in Help by using the keyword Color followed by a period txtName.ForeColor = Color.AliceBlue lblMessage.BackColor = Color.White 23

With and End With Change several properties at once in Code Will run more efficiently With txtName .Visible = True .Text ="Lynne" . Focus( ) End With 24

Concatenation Think of it as "glueing" text strings together Example: txtFName contains First Name txtLName contains Last Name lblFullName.Text = txtFName.Text & " " & txtLName.Text lblNote.Text = "Today's weather is " & txtWeather.Text & "." 25

Continuing Lines of Code For long lines of code it is more readable to continue them to the next line At the end of the line type Line Continuation Character, a Space followed by an Underscore lblMessage.Text = txtFName.Text & "" & txtLName.Text & _ ", welcome to Aiken Technical College. Today is " & _ txtToday.Text 26