Windows Controls Add controls to Make selections Add links Add images Choose a date or number Time events Make menu choices Respond to dialogs.

Slides:



Advertisements
Similar presentations
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Advertisements

Chapter 3 Creating a Business Letter with a Letterhead and Table
Introduction to Microsoft Excel 2010 Chapter Extension 3.
FrontPage Express By John G. Summerville Ph.D.©, RN.
EXCEL Spreadsheet Basics
© by Pearson Education, Inc. All Rights Reserved. continued …
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.
 2006 Pearson Education, Inc. All rights reserved Introduction to the Visual C# 2005 Express Edition IDE.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
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.
Creating Tables in a Web Site Using an External Style Sheet HTML5 & CSS 7 th Edition.
Printing and Page Formatting ITSW 1401, Intro to Word Processing Instructor: Glenda H. Easter.
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 2005 CHAPTER 8 Using Procedures and Exception Handling.
Tutorial 6 Using Form Tools and Creating Custom Forms
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
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 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Microsoft Word 2000 Presentation 5. Major Word Topics Columns Tables Lists.
Microsoft Expression Web-Illustrated Unit I: Working with Tables.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
 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.
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.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
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 1 Creating a Dreamweaver Web Page and Local Site
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 3.1 Test-Driving the Welcome Application 3.2.
 2006 Pearson Education, Inc. All rights reserved Introduction to the Visual C# 2005 Express Edition IDE.
OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter.
Chapter 2 – Introduction to the Visual Studio .NET IDE
More Controls and Their Properties Part 4 dbg --- TextBox, CheckBox, RadioButton, GroupBox, ToolTips,
1 Excel Lesson 1 Microsoft Excel Basics Microsoft Office 2010 Pasewark & Pasewark.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
COMPUTER PROGRAMMING I 3.02 Apply Properties Associated with the Controls.
 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.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
1 Windows Forms II Chapter RadioButton / GroupBox Controls Used to solicit a multiple choice input. Radio buttons work as a group. Selecting one.
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.
Graphical User Interface Concepts - Part 1 Session 08 Mata kuliah: M0874 – Programming II Tahun: 2010.
Lecturer: Dalia Mirghani
Chapter 1: An Introduction to Visual Basic .NET
Computing with C# and the .NET Framework
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
3.01 Apply Controls Associated With Visual Studio Form
Chapter 2 – Introduction to the Visual Studio .NET IDE
The University of Texas – Pan American
Presentation transcript:

Windows Controls Add controls to Make selections Add links Add images Choose a date or number Time events Make menu choices Respond to dialogs

RadioButton May display text, an image, or both Radio buttons from a group user must select exactly one Example3-1 has three radio buttons Each represents a color User selection changes Label text to the selected color

Drag radio buttons to form

Example3-1

Configure Properties BackColorRed Font BoldTrue TextRed AnchorTop (Name)redButton (Similarly for the other two radio buttons)

Configuring the Label BorderStyleFixed3D Font Size14 TextThe text color is black TextAlignMiddleCenter AnchorLeft, Right Namedisplay

The BorderStyle property Used for the Label NoneThe default FixedSingleFrames the label with black rectangle Fixed3DRecesses the label

Handling a radio button click private void redRadio_CheckedChanged (object sender, System.EventArgs e) { display.ForeColor = Color.Red; display.Text = "The color is red"; } Changes the foreground color and text of the label

The LinkLabel control Lets us add links to web sites This links to a site with information about George Washington

Handle a Link Click Use the Start method of the Process class to start the Internet Explorer browser with the desired web site Event handling code: private void presidentLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start(“IEExplore”, “ }

Add Radio Buttons to select

Handling a radio button selection When the user selects a radio button we want to do three things Show the president’s name in the link Underline the link Associate the link with the site containing the president’s biography.

The event handling code private void george_CheckedChanged (object sender, System.EventArgs e) { presidentLink.Text = "George Washington"; presidentLink.LinkBehavior = LinkBehavior.AlwaysUnderline; presidentLink.Links[0].LinkData = " }

A Collection Of Links A LinkLabel may have a collection of links. The Links property holds that collection Links[0] refers to the first link in the collection. The LinkLabel in Example3-2 has only one link The LinkData specifies the web site for the link

Grouping Radio Buttons Drag a GroupBox to the Form Add each RadioButton to the GroupBox GroupBox has a border with a title Change its Text property to Choose a President To change the title in the group box border A Form may have more than one group

Selecting a Style The Border Style group box Choose a border style for the link label The user chooses exactly one radio button from each group – one to choose the president and one to choose the border style

Border Style event handling private void singleBorder_CheckedChanged (object sender, System.EventArgs e) { presidentLink.BorderStyle = BorderStyle.FixedSingle; } private void threeDBorder_CheckedChanged (object sender, System.EventArgs e) { presidentLink.BorderStyle = BorderStyle.Fixed3D; }

The PictureBox control

The SizeMode property Normal Places the image in the upper-left corner, clipped if too large StretchImageStretches or shrinks the image to fit AutoSizeResizes the PictureBox to the size of the image CenterImageDisplays the image in the center if the PictureBox is larger than the image. Centers and clips the image if it is larger.

Size modes in Example3-3 Left AutoSize Right (top to bottom) Normal CenterImage StretchImage Can set border styles too None, FixedSingle, or Fixed3D

The CheckBox control Make multiple selections Or select nothing May have a label, an image, a background image May appear with a box to check or like a button

Example3-4

Steps to add an image Click on the View, Properties menu item to show the list of properties. Click on the Image property to display a small button at the right. Click on the small button to pop up a window to open a file. Browse to locate the desired image and click the Open button.

Alignment ImageAlign property -- place the image at different positions within a CheckBox. CheckAlign property functions in the same way for the position of the box that the user checks. TextAlign property determines the placement of the text

Steps to set alignment Click on the View, Properties menu item to show the list of properties. Click on the ImageAlign, CheckAlign, or TextAlign property to display a small button at the right. Click on the small button to pop up a grid of three rows and three columns that allows us to choose the alignment position. Click to choose one of the nine positions. The three vertical positions Top, Middle, and Bottom combine with the three horizontal positions, Left, Center, and Right to give the nine choices.

FlatStyle property for CheckBox FlatThe box appears flat PopupAppears flat until the mouse passing over makes it appear three-dimensional StandardAppears three-dimensional SystemAppearance determined by the user’s operating system

Event-handling code private void berryBox_CheckedChanged (object sender, System.EventArgs e) { display.Text = "Strawberry " + berryBox.Checked; } Label shows the last box checked or unchecked

ListBox and ComboBox ListBox shows all the elements ComboBox pops them up Click on Items property to display a String Collection Editor to enter the items SelectedItem property refers to the selected item

Example3-5

String Collection Editor

ListBox SelectionMode NoneNo items can be selected OneOne item can be selected MultiSimpleMultiple items can be selected MultiExtendedMultiple items can be selected and the user can use the shift, control, and arrow keys to make the selection

Selecting a list item When the user selects an item, say hamburger Program displays message in a label hamburger has 9 letters build this expression in four parts hamburger the selected item has 9 the length of the selected word letters

ListBox event handler private void foodList_SelectedIndexChanged (object sender, System.EventArgs e) { display.Text = foodList.SelectedItem.ToString() + " has “ + foodList.SelectedItem.ToString().Length.ToString() + " letters"; }

ComboBox event handler private void drinksCombo_SelectedIndexChanged (object sender, System.EventArgs e) { display.Text = "It's " + foodList.SelectedItem.ToString() + " and " + drinksCombo.Text; } Display a message showing the food and drink selected

Keeping Track Various controls help us keep track of dates, time, and numbers DateTimePicker NumericUpDown StatusBar Timer

Example3-6

Example3-6 operation DateTimePicker at top of form User chooses a date NumericUpDown in the middle User selects a number Button at bottom User presses to display date in a label and number selected in another label StatusBar at bottom shows current time Timer updates it every second, and changes label colors

DateTimePicker Format LongTuesday, January 28, 2003 Short1/28/03 Time10:32:56 AM

Button Click handling private void showButton_Click (object sender, System.EventArgs e) { dateDisplay.Text = "Date selected: " + date.Value.ToLongDateString(); numberDisplay.Text = "Number selected " + number.Value.ToString(); }

A Timer control

Timer Tick event every second private void timer1_Tick (object sender, System.EventArgs e) { currentDateTime.Text = DateTime.Now.ToString(); number.BackColor = dateDisplay.BackColor; dateDisplay.BackColor = numberDisplay.BackColor; numberDisplay.BackColor = number.BackColor; } Copies time to status bar Permutes background colors to give flashing effect

Menus

Drag a MainMenu control

Add a File menu

Add menu items File menu Open, Save, Print Format menu Font, Color menu Foreground Background Click on menu item – Event handler pops up a dialog

Open menu click event handler private void openMenu_Click (object sender, System.EventArgs e) { openDialog.ShowDialog(); displayBox.LoadFile(openDialog.FileName, RichTextBoxStreamType.PlainText); } Pops up a dialog to select the file Loads the selected file in a RichTextBox

Save Click event handler private void saveMenu_Click (object sender, System.EventArgs e) { saveDialog.ShowDialog(); displayBox.SaveFile(saveDialog.FileName, RichTextBoxStreamType.PlainText); } Pops up a dialog to enter a file name Saves file in RichTextBox using that name

Foreground Menu Click private void foregroundMenu_Click (object sender, System.EventArgs e) { colorDialog.ShowDialog(); displayBox.ForeColor =colorDialog.Color; } Pops up a dialog to choose a color Changes the RichTextBox text color

Font Menu Click private void fontMenu_Click (object sender, System.EventArgs e) { fontDialog.ShowDialog(); displayBox.Font = fontDialog.Font; } Pops up a font dialog to choose a font Changes the font of the RichTextBox text

Example3-7