How to Add Images Using an 'openFile' Dialog

Slides:



Advertisements
Similar presentations
 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
Advertisements

Copyright © 2012 Pearson Education, Inc. Chapter 11 MORE WINDOWS CONTROLS & STANDARD DIALOG BOXES.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
File Handling Advanced Higher Programming. What is a file? Up until now, any stored data within a program is lost when the program closes. A file is a.
1 Prototyping for HCI Spring 2004 (Week 7) Jorge A. Toro.
.NET Class 4 – Windows-based Application. WinForm Application Homogeny programming model. Rich class library Classes are shared by all.NET languages.
Using Multiple Forms. Creating a New Form ProjectAdd Windows Form.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
Microsoft Visual Basic 2012 CHAPTER TEN Incorporating Databases with ADO.NET.
CIS 310: Visual Programming, Spring 2007 Western State College Welcome to 310 Visual Programming Spring, 2008.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
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.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
BIL528 – Bilgisayar Programlama II Introduction 1.
ADO.NET By Hanumantha Rao.N MCA By Hanumantha Rao.N MCA.
Visual C Sharp – File I/O - 1 Variables and arrays only temporary - lost when a program terminates Files used for long term storage (Data bases considered.
Windows Forms Programming in C# Windows Forms CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
Dr Dat Tran - Week 4 Lecture Notes 1 MenuStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
File Handling. Data Files Programs that can only get data from the user interface are limited. –data must be entered each time. –only small amounts of.
Object Oriented Programming Graphical User Interfaces Dr. Mike Spann
Session 08: Architecture Controllers or Managers Graphical User Interface (GUI) FEN AK - IT Softwarekonstruktion.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
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.
Dr Dat Tran - Week 4 Lecture Notes 1 ToolStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New.
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.
1 Scroll Bars Providing Scrollbars. 2 Objectives You will be able to: Use Windows Graphics to display tabular information on a Windows form. Add graphics.
Working with GridView Control: Adding Columns. Adding Buttons to a Bound GridView: 1. Drag the WebProduct table from Data connection to a page 2. Demo.
BIL528 – Bilgisayar Programlama II Introduction 1.
Lecture Set 12 Sequential Files and Structures Part A – Dialog Boxes, Filters, Directories.
Dynamic Dropdown Lists 1. Objectives You will be able to Use Dropdown Lists to solicit multiple choice user input in an ASPX web page. Populate a Dropdown.
Lecture 7 Dialog Controls MDI Parent/Child Interaction.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
CMAP Concept Mapping Activity Climate Change Unit.
Copyright © 2012 Pearson Education, Inc. Chapter 5 Loops, File, and Random Numbers.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Creating a Multiple-Form Interface.
Double click here to add event title Double click here to add event date Double click here to add event time Double click here to add event location.
1 Printing a Document. 2 Objectives You will be able to print a real multipage document.
BIL528 – Bilgisayar Programlama II Methods 1. Contents Methods 2.
Lecture Set 7 Procedures and Event Handlers Part B - The Structure of an Application Event Handlers.
Graphical User Interface Components Version 1.1. Obectives Students should understand how to use these basic Form components to create a Graphical User.
1 Windows Forms II Chapter RadioButton / GroupBox Controls Used to solicit a multiple choice input. Radio buttons work as a group. Selecting one.
11 User Controls Beginning ASP.NET in C# and VB Chapter 8.
Problem: Take Two Numbers, Add Them Together And Display The Results. Now To Build The Flowchart… We Probably Need One Like This… Let’s Add The Routines…
2-1 Chapter 2 Using VB.NET to Create a First Solution.
Windows form programming. namespace MyNamespace { public class MyForm : System.Windows.Forms.Form { public MyForm() { this.Text = "Hello Form"; }
Module 3: Creating Windows-based Applications. Overview Creating the Main Menu Creating and Using Common Dialog Boxes Creating and Using Custom Dialog.
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Computing with C# and the .NET Framework
Madlib-Input, Strings, and Lists in Scratch
Object Oriented Programming
Incorporating Databases with ADO.NET
Objective 8.02 Apply Procedures to Create Picture Boxes using Images.
Using Multiple Forms.
Visual studio 2010 SENG 403, Tutorial 2 SENG Winter 2011.
Incorporating Databases with ADO.NET
Picture Viewer.
MDI Picture Viewer Application
CIS16 Application Development and Programming using Visual Basic.net
Self Study GUI Properties & Events
Module 8: Creating Windows-based Applications
Searching Your Database
Menus and Dialogs.
CIS 338: Images on Forms Dr. Ralph D. Westfall May, 2009.
Lecture 5 Menu Strip Demo with Dialog Controls.
GUI Programming in Visual Studio .NET
4.4 – List vs Array Exercise 4.1: Array Variables
Presentation transcript:

How to Add Images Using an 'openFile' Dialog A Guide in 9 Steps (and abusing David Beckham in the process)

Creating Controls 1. Create a new PictureBox control 2. Create a new OpenFileDialog control (Note: although you drag it onto the form designer it does not show up on the form but in the area below the form designer)

Creating Defaults 3. In the Properties Manager add a background image with some info for the user how to add an image. (Note: create the image in, say, MS Paint with the same dimensions as the PictureBox)

Creating Defaults 4. In the Properties Manager set the image sizing behaviour to 'StretchImage" (otherwise all you images have to be of the same size as the pictureBox) 5. In the Properties Manager set the image type filter, e.g. to: JPG files |*.jpg|Bitmap files|*.bmp (Note: the vertical bars are required) 6. In the Properties Manager delete the default FileName and InitialDirectory (or set them to a default of your liking) All visual controls are now in place. Let's add some code…

Defining a Variable 7. Define a string variable to hold a pathname to the image public string ImgFilePathName; ImgFilePathName = ""; // You could set it to a default here

Adding new Images 8. Double-click on the PictureBox to create the event handler stub. Then add this code: private void pictureBox1_Click(object sender, EventArgs e) { openFileDialog1.Title = "Select an image file"; if (openFileDialog1.ShowDialog() == DialogResult.OK) ImgFilePathName = openFileDialog1.FileName; pictureBox1.ImageLocation = ImgFilePathName; } This line saves the file's path name This line shows the image

In the “Database” Project 9. You probably want to store the image in the “database”. The easiest way is not to store the image but just the filename.  Add a string to the struct, e.g: public string imageFileName;  In the OpenFile dialog code add 3 lines to store the filename: private void pictureBox1_Click(object sender, EventArgs e) { openFileDialog1.Title = "Select an image file"; if (openFileDialog1.ShowDialog() == DialogResult.OK) ImgFilePathName = openFileDialog1.FileName; pictureBox1.ImageLocation = ImgFilePathName; Member temp = Club[currentMemberShown]; temp.imageFileName = ImgFilePathName; Club[currentMemberShown] = temp; } THAT'S IT !