1 Windows Forms II Chapter 20. 2 RadioButton / GroupBox Controls Used to solicit a multiple choice input. Radio buttons work as a group. Selecting one.

Slides:



Advertisements
Similar presentations
© by Pearson Education, Inc. All Rights Reserved. continued …
Advertisements

 2006 Pearson Education, Inc. All rights reserved Introduction to the Visual C# 2005 Express Edition IDE.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
PictureBoxes A picture box displays an image. You can find it in toolbox, drag it in the form Images can be.bmp,.gif,.jpg, jpeg GIF and JPEG files are.
Microsoft Visual Basic 2012 CHAPTER TEN Incorporating Databases with ADO.NET.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
PictureBox, Timer, Resources. Resources An easy and effective way to add pictures (photos, graphics) to your programs Using Resources guarantees that.
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,
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
1 Windows Printing. 2 Objectives You will be able to Output text and graphics to a printer. Print multipage documents. Use the standard Windows print.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Dreamweaver CS4 Concepts and Techniques Chapter 7 Page Layout with Frames.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
CIS 338: Creating ActiveX Controls Dr. Ralph D. Westfall March, 2003.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
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 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
1 Working with Menus and Dialog Boxes. 2 Objectives You will be able to Create and edit menus for Windows Forms applications. Write code to handle menu.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
CIS 205—Web Design & Development Fireworks Chapter 1.
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.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
BIL528 – Bilgisayar Programlama II Introduction 1.
Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services.
Lecture 6: Introduction to Graphical User Interfaces (GUIs)
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
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.
COMPUTER PROGRAMMING I SUMMER 2011 Objective 8.02 Apply Procedures to Create Picture Boxes using Images. (5%)
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al- ajmi Chapter 3 Some Visual Basic Controls and Events Visual Basic. NET.
Images Part 11 dbg. 2 Images The form and several controls can display a number of different types of image files in the BackgroundImage Property. These.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
11 User Controls Beginning ASP.NET in C# and VB Chapter 8.
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.
 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.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Graphical User Interface Concepts - Part 1 Session 08 Mata kuliah: M0874 – Programming II Tahun: 2010.
PictureBox, MessageBox, Multiple Forms, Splash Screens and Timers
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
Incorporating Databases with ADO.NET
Objective 8.02 Apply Procedures to Create Picture Boxes using Images.
3.01 Apply Controls Associated With Visual Studio Form
Introduction to the Visual C# 2005 Express Edition IDE
Using Procedures and Exception Handling
Visual programming Chapter 3: GUI (Graphical User Interface) Part I
Program and Graphical User Interface Design
Incorporating Databases with ADO.NET
Chapter 2 – Introduction to the Visual Studio .NET IDE
Lesson 04 Control Structures I : Decision Making
The University of Texas – Pan American
Part A – Doing Your Own Input Validation with Simple VB Tools
6. WinForms 2003 C# GUI - Basics.
CIS 338: Images on Forms Dr. Ralph D. Westfall May, 2009.
Presentation transcript:

1 Windows Forms II Chapter 20

2 RadioButton / GroupBox Controls Used to solicit a multiple choice input. Radio buttons work as a group. Selecting one unselects any previous choice. The GroupBox defines the group. Expand “All Windows Forms” in Toolbox. Drag GroupBox to the form. Drag four radio buttons from the Toolbox and drop inside the GroupBox. You can also copy and paste controls. Ctrl-C, Ctrl-V

3 GroupBox Properties Text Property Location and size are normally set interactively via the designer. The usual appearance properties are available.

4 RadioButton Properties Checked is true for a button that is selected. (Max of 1 per group.) Text

5 Add an OK Button

6 Code for Button Click Event enum Classification {Unknown, Freshman, Sophomore, Junior, Senior}; Classification year = Classification.Unknown; private void btnOK_Click(object sender, System.EventArgs e) { if (rbFreshman.Checked) year = Classification.Freshman; else if (rbSophomore.Checked) year = Classification.Sophomore; else if (rbJunior.Checked) year = Classification.Junior; else if (rbSenior.Checked) year = Classification.Senior; if (year == Classification.Unknown) MessageBox.Show("Please select year"); else MessageBox.Show("You will be recorded as a " + year.ToString()); } End of Section

7 The PictureBox Control Allows you to include images on your form. Typically a jpeg or gif file Other possibilities. Important Properties: Image (Browse to file) Location Size SizeMode Normal, StretchImage, AutoSize, CenterImage, Zoom BorderStyle

8 The PictureBox Control Need an image file? Try google > images From search on University of South Florida Image file is in Downloads area of class web site: Downloads/USF_Bull.gif Downloads/USF_Bull.gif Download to desktop

9 The PictureBox Control

Setting the Image Property Select the Image property. Click on the elipses (...) button. 10

Setting the Image Property Click on Import. 11

Setting the Image Navigate to the image file. Select the file and click Open. 12

Setting the Image Click OK. 13

Setting the Image The image file has been copied into the project. 14

15 SizeMode Values From the Help page for SizeMode: Valid values for this property are taken from the PictureBoxSizeMode enumeration. By default, in PictureBoxSizeMode.Normal mode, the Image is placed in the upper left corner of the PictureBox, and any part of the image too big for the PictureBox is clipped. PictureBoxSizeMode.Zoom causes the image to be stretched or shrunk to fit the PictureBox, while maintaining the aspect ratio. Using the PictureBoxSizeMode.StretchImage value causes the image to stretch to fit the PictureBox. Using the PictureBoxSizeMode.AutoSize value causes the control to resize to always fit the image. Using the PictureBoxSizeMode.CenterImage value causes the image to be centered in the client area. 15

The PictureBox Control Set size mode to Zoom. Build and run. 16

17 SizeMode Zoom SizeMode = Zoom

18 SizeMode Normal SizeMode = Normal

19 CenterImage SizeMode = CenterImage

20 AutoSize SizeMode = Autosize Most of the PictureBox falls outside the form.

AutoSize Window resized to hold entire PictureBox control. 21

22 The PictureBox Control Conclusions: Try to match size of actual image to size that you need on the form. If not, Zoom is usually the best bet. But, at least, be sure the ratio of height to width is about the same. End of Section

Where is the image? It's embedded in the program You don't need to retain or deploy the original image file. 23

Form1.resx In the project folder, you can drill down and find the file. 24

Form1.resx 25

Form1.resx 26

Form1.resx 27

Form1.resx End of Section 28

29 The ComboBox Control “Combination” of text entry box and dropdown list. Select from list or enter text. Important Properties: Items(Collection of strings to display.) Can be set using the designer or by program. DropDownStyle SimpleText Entry Only DropDownText Entry or Select DropDownListSelect Only TextWhatever was selected or entered

30 The ComboBox Control Set name to cbYear.

Setting the Choices 31

Setting the Choices Click OK. 32

Getting the User’s Choice Build and run. 33

Program Running 34

35 The ComboBox Control After clicking on the arrow:

36 The ComboBox Control After user selects Sophomore

Getting the User’s Choice End of Section 37

38 Handling the FormClosing Event In Design View, select the form (by clicking anywhere on the background.) In the Properties window, select Events. (Lightening bolt icon at top of window.) Beside “FormClosing” type the name that you want to give to the event handler (e.g., FormIsClosing) Don't use the event name, FormClosing. Press Enter.

Setting the Event Handler 39

40 Handling the FormClosing Event This creates the following stub in the code file: private void FormIsClosing( object sender, System.ComponentModel.CancelEventArgs e) { } This function will be called when the user clicks the Close button on the form.

41 Using a MessageBox to Get User Input Add this code inside the FormIsClosing function. DialogResult result = MessageBox.Show("Are you sure you want to quit?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); e.Cancel = (result == DialogResult.No);

42 MessageBox Example MessageBox.Show("Are you sure you want to quit?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

43 Add a Close Button

44 Close Button Click Event Handler private void btnClose_Click(object sender, EventArgs e) { this.Close(); }

45 We still get the FormClosing Event End of Section

46 Summany Visual Studio makes it easy to create simple Windows forms applications. There is an enormous amount of information about Windows forms. Only a small amount of it is necessary in order to create simple applications. Need to be aware of what exists. Need to be able to find what you need when you need it. End of Presentation