Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.

Slides:



Advertisements
Similar presentations
Information System Design Lab 5&6. User Interface Design.
Advertisements

What is a Dialog box? A Dialog box is a window or “form” that contains other child windows or “controls” that have a specific appearances and pre-defined.
Using Macros and Visual Basic for Applications (VBA) with Excel
© 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,
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
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.
Programming Based on Events
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
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,
1 Web-Enabled Decision Support Systems Windows Forms and Controls Prof. Name Position (123) University Name.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
 2009 Pearson Education, Inc. All rights reserved Introduction to the Visual Basic Express 2008 IDE.
 2009 Pearson Education, Inc. All rights reserved Dive Into ® Visual C# 2008 Express.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
© 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.
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.
Graphical User Interfaces 2 Tonga Institute of Higher Education.
Creating Buttons – Lesson 51 Creating Buttons Lesson 5.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2 – Introduction to the Visual Studio .NET IDE
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.
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.
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.
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.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
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.
AdditionalControls 1. The MenuStrip 2 Double-click Let’s begin to design the menu bar for VB! Let’s begin to design the menu bar for VB! 3.
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.
PowerPoint Chapter 1 Creating and Editing a Presentation with Clip Art Discovering Computers & Microsoft Office 2010.
 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.
Dive Into® Visual Basic 2010 Express
Graphical User Interface
Chapter 1: An Introduction to Visual Basic 2015
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
Graphical User Interface Concepts: Part I
3.01 Apply Controls Associated With Visual Studio Form
Chapter 2 Adding Web Pages, Links, and Images
Chapter 2 – Introduction to the Visual Studio .NET IDE
The University of Texas – Pan American
Week 2: WINDOWS PROGRAMMING
Presentation transcript:

Chapter 12: Using Controls

Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton A Label has been dragged onto Form1 and its properties updated A Button has been dragged onto Form1 and its properties updated 2Microsoft Visual C# 2012, Fifth Edition

3 Examining the IDE’s Automatically Generated Code (cont’d.)

Within the Form1.Designer.cs file in Visual Studio, two lines of code are generated as follows: private System.Windows.Forms.Label label1; private System.Windows.Forms.Button okButton; These lines appear under a gray box that contains Windows Form Designer generated code Expand the code generated by clicking the + in the method node or double-clicking the gray box 4Microsoft Visual C# 2012, Fifth Edition

5 Examining the IDE’s Automatically Generated Code (cont’d.)

Setting a Control ’s Font Use the Font class to change the appearance of printed text on your Form s Change the appearance of printed text using code – Create your own instance of the Font class The class includes a number of overloaded constructors Example: System.Drawing.Font bigFont = new System.Drawing.Font("Courier New", 16.5f); this.label1.Font = bigFont; this.okButton.Font = bigFont; 6Microsoft Visual C# 2012, Fifth Edition

Setting a Control ’s Font (cont’d.) 7Microsoft Visual C# 2012, Fifth Edition

8 Setting a Control ’s Font (cont’d.)

9Microsoft Visual C# 2012, Fifth Edition Setting a Control ’s Font (cont’d.)

Using a LinkLabel LinkLabel – Similar to a Label – Provides the additional capability to link the user to other sources Such as Web pages or files Default event – The method whose shell is automatically created when you double-click the Control – The method you are most likely to alter with Control – The event that users most likely expect to generate 10Microsoft Visual C# 2012, Fifth Edition

Using a LinkLabel (cont’d.) 11Microsoft Visual C# 2012, Fifth Edition

LinkLabel appears as underlined text – The text is blue by default When you pass the mouse pointer over a LinkLabel, the pointer changes to a hand When a user clicks a LinkLabel, it generates a click event – Executing a LinkClicked() method The LinkVisited property can be set to true when you determine that a user has clicked a link 12Microsoft Visual C# 2012, Fifth Edition Using a LinkLabel (cont’d.)

13Microsoft Visual C# 2012, Fifth Edition Using a LinkLabel (cont’d.)

14Microsoft Visual C# 2012, Fifth Edition Using a LinkLabel (cont’d.)

15Microsoft Visual C# 2012, Fifth Edition Using a LinkLabel (cont’d.)

Adding Color to a Form Color class – Contains a wide variety of predefined Color s that you can use with your Control s You can change a Form ’s color using its BackColor and ForeColor properties 16Microsoft Visual C# 2012, Fifth Edition

Using CheckBox and RadioButton Objects CheckBox objects – GUI widgets the user can click to select or deselect an option RadioButton s – Similar to CheckBox es – Only one RadioButton in a group can be selected at a time 17Microsoft Visual C# 2012, Fifth Edition

Using CheckBox and RadioButton Objects (cont’d.) 18Microsoft Visual C# 2012, Fifth Edition

19Microsoft Visual C# 2012, Fifth Edition Using CheckBox and RadioButton Objects (cont’d.)

20Microsoft Visual C# 2012, Fifth Edition Using CheckBox and RadioButton Objects (cont’d.)

21Microsoft Visual C# 2012, Fifth Edition Using CheckBox and RadioButton Objects (cont’d.)

22Microsoft Visual C# 2012, Fifth Edition Using CheckBox and RadioButton Objects (cont’d.)

Adding a PictureBox to a Form PictureBox – A Control in which you can display graphics from a bitmap, icon, JPEG, GIF, or other image file type 23Microsoft Visual C# 2012, Fifth Edition

24Microsoft Visual C# 2012, Fifth Edition

25Microsoft Visual C# 2012, Fifth Edition Adding a PictureBox to a Form (cont’d.)

26Microsoft Visual C# 2012, Fifth Edition Adding a PictureBox to a Form (cont’d.)

Adding ListBox, CheckedListBox, and ComboBox Control s to a Form ListBox, ComboBox, and CheckedListBox objects – List-type widgets that descend from ListControl ListBox Control – Displays a list of items the user can select by clicking – Allows the user to make a single selection or multiple selections by setting the SelectionMode property – SelectedItem property Contains the value of the item a user has selected 27Microsoft Visual C# 2012, Fifth Edition

28 Adding ListBox, CheckedListBox, and ComboBox Control s to a Form (cont’d.) Microsoft Visual C# 2012, Fifth Edition

29Microsoft Visual C# 2012, Fifth Edition Adding ListBox, CheckedListBox, and ComboBox Control s to a Form (cont’d.)

30Microsoft Visual C# 2012, Fifth Edition Adding ListBox, CheckedListBox, and ComboBox Control s to a Form (cont’d.)

31Microsoft Visual C# 2012, Fifth Edition Adding ListBox, CheckedListBox, and ComboBox Control s to a Form (cont’d.)

32Microsoft Visual C# 2012, Fifth Edition Adding ListBox, CheckedListBox, and ComboBox Control s to a Form (cont’d.)

ComboBox Control – Similar to a ListBox – Displays an additional editing field Allows the user to select from the list or to enter new text CheckedListBox Control – Similar to a ListBox – Check boxes appear to the left of each desired item 33Microsoft Visual C# 2012, Fifth Edition Adding ListBox, CheckedListBox, and ComboBox Control s to a Form (cont’d.)

34Microsoft Visual C# 2012, Fifth Edition Adding ListBox, CheckedListBox, and ComboBox Control s to a Form (cont’d.)

Adding MonthCalendar and DateTimePicker Control s to a Form MonthCalendar and DateTimePicker Control s – Allow you to retrieve date and time information 35Microsoft Visual C# 2012, Fifth Edition

36Microsoft Visual C# 2012, Fifth Edition Adding MonthCalendar and DateTimePicker Control s to a Form (cont’d.)

37Microsoft Visual C# 2012, Fifth Edition Adding MonthCalendar and DateTimePicker Control s to a Form (cont’d.)

38Microsoft Visual C# 2012, Fifth Edition Adding MonthCalendar and DateTimePicker Control s to a Form (cont’d.)

39Microsoft Visual C# 2012, Fifth Edition Adding MonthCalendar and DateTimePicker Control s to a Form (cont’d.)

DateTimePicker Control – Displays a month calendar when the down arrow is selected 40Microsoft Visual C# 2012, Fifth Edition Adding MonthCalendar and DateTimePicker Control s to a Form (cont’d.)

41Microsoft Visual C# 2012, Fifth Edition Adding MonthCalendar and DateTimePicker Control s to a Form (cont’d.)

42Microsoft Visual C# 2012, Fifth Edition Adding MonthCalendar and DateTimePicker Control s to a Form (cont’d.)

Working with a Form ’s Layout Blue snap lines – Appear when you drag multiple Control s onto a Form – Help align new Control s with others already in place – Appear when you place a control closer to the edge of a container than is recommended Can use the Location property in the Properties list to specify a location 43Microsoft Visual C# 2012, Fifth Edition

Working with a Form ’s Layout (cont’d.) 44Microsoft Visual C# 2012, Fifth Edition

Working with a Form ’s Layout (cont’d.) Dock property – Attaches a Control to the side of a container so that the Control stretches when the container’s size is adjusted 45Microsoft Visual C# 2012, Fifth Edition

Working with a Form ’s Layout (cont’d.) 46Microsoft Visual C# 2012, Fifth Edition

Working with a Form ’s Layout (cont’d.) 47Microsoft Visual C# 2012, Fifth Edition

Understanding GroupBox es and Panel s GroupBox or Panel – Groups related Control s on a Form – Can be docked inside a Form GroupBox es – Can display a caption – Do not have scroll bars Panel s – Cannot display a caption – Have scroll bars 48Microsoft Visual C# 2012, Fifth Edition

Adding a MenuStrip to a Form Menu strip – A horizontal list of general options that appears under the title bar of a Form or Window You can add a MenuStrip Control object to any Form you create When you double-click an entry in the MenuStrip, a Click() method is generated 49Microsoft Visual C# 2012, Fifth Edition

Adding a MenuStrip to a Form (cont’d.) 50Microsoft Visual C# 2012, Fifth Edition

Adding a MenuStrip to a Form (cont’d.) 51Microsoft Visual C# 2012, Fifth Edition

52Microsoft Visual C# 2012, Fifth Edition Adding a MenuStrip to a Form (cont’d.)

Using Other Control s If you click Project on the main menu and click Add New Item, you can add extra Form s, File s, Control s, and other elements to your project 53Microsoft Visual C# 2012, Fifth Edition

You Do It Adding Label s to a Form and Changing Their Properties Examining the Code Generated by the IDE Adding CheckBox es to a Form Adding RadioButton s to a Form 54Microsoft Visual C# 2012, Fifth Edition