1 Chapter Ten Using Controls. 2 Objectives Learn about Controls How to create a Form containing Labels How to set a Label’s Font How to add Color to a.

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Select Case Statements and Selection Input.
Advertisements

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
© by Pearson Education, Inc. All Rights Reserved. continued …
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Microsoft Visual C#.NET: From Problem Analysis to Program Design1 Chapter 9 Programming Based on Events Microsoft Visual C#.NET: From Problem Analysis.
C# Programming: From Problem Analysis to Program Design1 9 Programming Based on Events.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
Programming Based on Events
Group Boxes and Panels Arrange components on a GUI Buttons and etc. can be placed inside a group box or panel. All these buttons move together when the.
Programming Based on Events
List-based Controls. Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
C# Programming: From Problem Analysis to Program Design1 Introduction to Windows Programming C# Programming: From Problem Analysis to Program Design 3.
Getting Started Example ICS2O curriculum
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Introducing Web Controls Outline 29.1 Analyzing the.
Chapter 8: Writing Graphical User Interfaces
IE 411/511: Visual Programming for Industrial Applications
CSCI 3328 Object Oriented Programming in C# Chapter 2: Introduction to Visual C# Programming 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Some Interesting Controls. Controls We've UsedNew Controls LabelListBox TextBoxCheckedListBox ComboBoxTabControl ButtonTabPage Menu MenuItem TreeView.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Controls in C++/CLI (2) CheckBox RadioButton GroupBox ListBox.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 3.1 Test-Driving the Welcome Application 3.2.
1 Chapter Nine Using GUI Objects and the Visual Studio IDE.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Controls Part 2. DateTimePicker Control Used for representing Date/Time information and take it as input from user. Date information is automatically.
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.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
 2007 Pearson Education, Inc. All rights reserved Introduction to the Visual Basic Express 2005 IDE.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Hamilton Software Products The Measure of Excellence Customized dialog.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
Computing with C# and the .NET Framework
Chapter Topics 15.1 Graphical User Interfaces
CSCI 3328 Object Oriented Programming in C# Chapter 2: Introduction to Visual C# Programming UTPA – Fall 2012 This set of slides is revised from lecture.
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
Using GUI Objects and the Visual Studio IDE
Programming Based on Events
Creating a Windows Forms User Interface
Chapter 15: GUI Applications & Event-Driven Programming
Visual C# - GUI and controls - 1
Presentation transcript:

1 Chapter Ten Using Controls

2 Objectives Learn about Controls How to create a Form containing Labels How to set a Label’s Font How to add Color to a Form How to add CheckBox and RadioButton objects to a Form

3 Objectives How to add a PictureBox to a Form How to add ListBox, ComboBox, and CheckedListBox items to a Form How to add functionality to a ListBox with one SelectedItem How to add functionality to a ListBox with multiple SelectedItems How to supply a default selection for a ListBox

4 Understanding Controls The Control class provides the definition for GUI objects such as Forms and Buttons The Control class has 23 direct descendants, some of which have their own descendants The Visual Studio Help documentation can be a useful resource when using Controls

5 Understanding Controls Control’s inheritance hierarchy

6 Understanding Controls A MarshalByRefObject object is one you can instantiate on a remote computer The Component class provides containment and cleanup for other objects The Control class implements very basic functionality required by classes that appear to the user The Control class handles user input through the keyboard and pointing device

7 Creating a Form with Labels A Label is one of the simplest GUI Control objects you can place on a form You typically use a Label control to provide descriptive text for another Control You can create a Label by calling the class constructor

8 Creating A Form with Labels FormWithLabels program and Output

9 Setting a Label’s Font You use the Font class to change the appearance of printed text on your Forms If the font size contains a decimal point, it must be of type float You can create a Font using FontStyles Once you have defined a Font, you can set a Label’s Font with a statement like label1.Font = myFont

10 Setting a Label’s Font Font dialog box

11 Setting a Label’s Font Label with new Font, FontStyle, and Size

12 Adding Color to a Form The Color class contains a wide variety of predefined Colors that you can use with your Controls Visual Studio also allows you to create custom colors Examples of using Colors: label1.BackColor = System.Drawing.Color.Blue; label1.BackColor = Color.Blue;

13 Using CheckBox and RadioButton Objects The ButtonBase class has three direct descendants: Button, CheckBox, and RadioButton When a Form contains CheckBoxes, any number of them can be checked or unchecked at the same time RadioButtons are similar to CheckBoxes, except that when placed on a Form, only one RadioButton can be selected at a time Both CheckBox and RadioButton objects have a Checked property and a CheckedChanged() method

14 Adding a PictureBox to a Form A PictureBox is a Control in which you can display graphics Lincoln Room Form with Image

15 Adding ListBox, CheckListBox, and ComboBox Controls to a Form ListBox,ComboBox, and CheckedListBox objects descend from the same family—they all are list-type widgets that descend from ListControl The ListBox Control enables you to display a list of items that the user can select by clicking With a ListBox, you can allow the user to make a single selection only or multiple selections by setting the SelectionMode property

16 Adding Functionality to a ListBox with One SelectedItem The SelectedItem property of a ListBox contains the value of the item a user has selected The easiest way to add functionality to a ListBox is by using the Visual Studio IDE

17 Adding Functionality to a ListBox with One SelectedItem Using the String Collection Editor to type ListBox options

18 Adding Functionality to a ListBox with One SelectedItem Selecting a ListBox option to change a Label

19 Adding Functionality to a ListBox with Multiple SelectedItems When you create a ListBox, by default its SelectionMode is One When a ListBox mode allows for more than one selection you use the SelectedItems array that contains a list of all currently selected item names You access each SelectedItems element in the same way you access any other array element You can determine how many items are selected by using the SelectedItems.Count field

20 Adding Functionality to a ListBox with Multiple SelectedItems Application that uses a ListBox that allows multiple selections

21 Supplying a Default Selection for a ListBox When you execute a program containing a ListBox, at first no items are selected; highlighting appears within a ListBox only after you click an option You can force an item to be the default by using the SetSelected() method The SetSelected() method requires two arguments—the position of the item to select and a Boolean value

22 Supplying a Default Selection for a ListBox Typical execution of Hemingway Homes application

23 Chapter Summary The Control class provides the definitions for GUI objects Typically, you use a Label control to provide descriptive text for another Control object You use the Font class to change the appearance of printed text on Forms The Color class contains a wide variety of predefined Colors that you can use with your Controls The Button, CheckBox, and RadioButton classes all descend from ButtonBase

24 Chapter Summary A PictureBox is a Control in which you can display graphics from a bitmap, icon, JPEF, GIF, or other image file type ListBox, ComboBox, and CheckedListBox objects descend from the same family The SelectedItem property of a ListBox contains the value of the item a user has selected When a ListBox mode allows for more than one selection, instead of a SelectedItem field, you use a SelectedItems array You can use the SetSelected() method to force a ListBox item to be the default