Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al- ajmi Chapter 3 Some Visual Basic Controls and Events Visual Basic. NET.

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Advertisements

Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Excel and VBA Creating an Excel Application
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Flowchart Start Input weight and height
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Chapter 7: Sub and Function Procedures
1 Chapter 5: Introduction To Form Builder. 2 Forms  Why Do We Use Form Builder?  Why Don’t We Use SQL Only?!
Chapter 2 User Interface Design Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Controls General Discussion. VB Controls Visual Basic Controls A control is the generic name for any object placed on a form Controls may be images,
Programming with Microsoft Visual Basic th Edition CHAPTER SEVEN SUB AND FUNCTION PROCEDURES.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Chapter 8: Writing Graphical User Interfaces
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 21 Fields and Forms.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
ACCESS Part 2. OBJECTIVES  Use the Form Wizard  Create a split form  Use Form Layout View  Add fields to a form  Modify form controls  Create calculations.
Programming with Microsoft Visual Basic 2008 Fourth Edition
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Seven More on the Repetition Structure.
Chapter 2 - More Controls More controls – Text boxes - used for user input – Frames - containers to group items – check boxes - user select an option -
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Chapter 6: The Repetition Structure
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
IS437: Spring 2006 Instructor: Dr. Boris Jukic Controls.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
1.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
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/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
7-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code that may be executed several times. Fixed-count (definite) loops repeat a fixed.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Unit 6 Repetition Processing Instructor: Brent Presley.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code (loop body) that may be executed several times. Fixed-count (definite) loops repeat.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
1 Chapter 6: Creating Oracle Data Block Forms. 2 Forms  Application with a graphical user interface that looks like a paper form  Used to insert, update,
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Microsoft Visual Basic 2008: Reloaded Third Edition
Chapter 1: An Introduction to Visual Basic 2015
Chapter 8: Writing Graphical User Interfaces
Building a User Interface with Forms
Repeating Program Instructions
Microsoft Visual Basic 2005: Reloaded Second Edition
CIS 16 Application Development Programming with Visual Basic
Presentation transcript:

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al- ajmi Chapter 3 Some Visual Basic Controls and Events Visual Basic. NET

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Objectives Have a clear understanding of the important features and the role various controls play in the user interface for data-entry operations Set the tab order for the controls placed on the form Understand the nature and uses of various events

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Obtaining Open-Ended Input Text box – Has a Text property – Should have a label giving a clue what goes in the box Masked Edit Box – Has a Mask property Mask can contain placeholders (#,A) or literals (-,()) – Has a Text property The exact content of the box, including literals – Has a ClipText property Content of the box, without literals

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Focus Control must have focus to accept data input – Press Tab key until you get to the control – Click on the control – By code, using the Focus method Focus method should be part of button click events or error handling procedures When a text box gets focus, a blinking cursor appears in box Enter event is triggered when a control receives focus

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Comparing Text Properties Setting at design time – Can only be done with text box Setting at runtime – With text box, can set to anything – With masked edit, text must match mask pattern Clearing at runtime – With text box, set to zero-length string – 3 steps for masked edit: Clear the mask Set text to zero-length string Redefine the mask

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Highlighting Text SelectedText property of text box gives the text that is highlighted – Corresponding property for masked edit: SelText SelectionStart property of text box gives the position where highlight begins – Corresponding property for masked edit: SelStart SelectionLength property of text box gives the length of highlighted text – Corresponding property for masked edit: SelLength

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Highlighting the Text Len(txtName.Text) returns number of characters. SelectionLength = Len(txtName.Text) will cause all characters in text box to be selected

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Highlighting the Text Text in txtName is highlighted when user tabs in. User can type new name without using the Delete key to get rid of old text. Makes application more friendly

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Arranging Many Controls Group box – Used to group related data fields – Controls inside box treated as one logical unit If you delete the group box, all controls deleted Tab control Tab control – Organizes a window into logical tabbed pages Both considered “containers” – They have the capability to hold other controls

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Data with Limited Number of Choices Radio button – Only one button in a group can be selected Good for mutually exclusive options, i.e. Male or Female – To allow multiple radio buttons to be selected on a window, use multiple containers Check box – User can select as many items as he/she wants Good for independent, rather than mutually exclusive options Both have Text and Checked properties – Text property is the text next to the control – Checked can be True or False

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Longer List of Known Items List box – Contains a list of items a user can select from – User can not enter items not in the list – User may have option to select multiple items Good alternative to check boxes Combo box – Contains a list of items a user can select from – User may enter items not in the list – User can only select one item Good alternative to radio buttons

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Common Methods and Properties SelectedItem property – Indicates the item selected (the text) SelectedIndex property – Indicates the position of the item clicked The first item has a SelectedIndex value of 0 Items.Add method – Adds items to list box or combo box Items.Count property – Gives the number of items in the list or combo box

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Selecting Items from the List Box SelectionMode property determines how items are selected – When set to One, only one item can be selected – When set to MultiSimple or MultiExtended, user can select multiple items GetSelected method used to determine whether or not an item is selected – Syntax: Listbox.GetSelected(Index)

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Selecting Items from the Combo Box Combo box has a text box area and list box DropDownStyle property determines whether or not user can enter data not in list – DropDown style (default) Fixed height; user can select from list or enter text – Simple style Adjustable height; user can select from list or enter text – DropDownList style user can only select an item from the list

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Graphics in the Visual Interface The Picture box – Has an Image property – Has a SizeMode property Normal: size of picture box drawn on form sets boundary for the picture StretchImage: size of image adjusted to fit the picture box AutoSize: size of picture box adjusted to fit image CenterImage: image appears in center of picture box Use only company logos or art that is professionally designed for this application

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Setting the Image Property Setting at design time – Set the Image property in the Properties box Setting at runtime – Use the Image.FromFile method to load the picture If you use this image, you run the risk that someone has moved or deleted the file Write a routine to allow the user to select the picture in the event it has been moved or deleted

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Naming Conventions: Prefixes

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Setting Tab Order Tab order: the order in which a VB control receives focus when user presses Tab key – Determined by control’s TabIndex property Tab order is an important component of a user-friendly interface – user should not jump all over the form when he/she tabs Form must have focus to set tab order

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi The Tab Order

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Common Events Form Load event – occurs when form is loaded into memory before form is displayed – all controls are set to initial states Click event – occurs when a user clicks a control normally associated with a button SelectedIndexChanged event – occurs when the user selects an item in the list box or combo box

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Common Events KeyPress event – occurs when the user presses a key often used for data validation Enter event – occurs when a control receives focus performs some “preparatory” activities Leave event – occurs when user leaves a control perform some finishing touches, such as field validation

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi An Application Example The Environ-Pure Project Analyze and define requirements – An easy to use interface to take orders from distributors Define the controls needed for the visual interface – Determine the data fields to be entered – Determine the appropriate type of control for each data field Set the Tab Order – Window has a vertical layout, so tab order should flow from top to bottom

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi An Application Example The Environ-Pure Project Code the Event Procedures – Several types of procedures needed Form Load procedure sets default values Validation procedures needed for several controls Radio buttons should be enabled only if this is a rush order Need procedures to save the data and to exit the application Test the Project – Create a test plan to test every control – Try to make the application break!

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi The Visual Interface

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Summary Different controls have different uses – text boxes for open-ended data – masked edit boxes for data with defined pattern – radio buttons for data with limited number of mutually exclusive choices – check boxes for data with limited number of independent choices – list boxes for relatively large list with independent choices – combo boxes for relatively large list with mutually exclusive choices

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Summary Containers are used to hold other items – group boxes used to group related data fields – tab controls used to group data into tabbed pages Change tab order of controls to make interface more user-friendly – form must have focus to change tab order

Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Summary Different events can have different uses – Form Load event initializes values of variables and controls – Click event responds to user clicks on buttons, etc – SelectedIndexChanged event occurs when the user clicks on list boxes and combo boxes – KeyPress event previews keystrokes before displaying in control – Enter event performs preparatory tasks, such as highlighting text – Leave event performs finishing touches