GUI Programming Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.

Slides:



Advertisements
Similar presentations
6. WinForms: GUI Programming in.NET. 2 Microsoft Objectives.NET supports two types of form-based apps, WinForms and WebForms. WinForms are the traditional,
Advertisements

Chapter 1: An Introduction to Visual Basic 2012
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Flowchart Start Input weight and height
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.
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab2 Managing Controls.
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
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.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
IE 411/511: Visual Programming for Industrial Applications
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
The Fundamentals of Using Windows 95. Windows 95 ã operating system that performs every function necessary for the user to communicate and control computer.
Dr Dat Tran - Week 1 Lecture Notes 1 Windows Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Lecture 6: Introduction to Graphical User Interfaces (GUIs)
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
BIM211 – Visual Programming Interacting with Users Graphics 1.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Introduction to Visual Studio & GUI Programming Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
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.
Michael Olivero Microsoft Student Ambassador for FIU Pick up your free drink below to your left. 1 per person please.
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.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 4: Intro to GUIs and the.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Chapter 1: An Introduction to Visual Basic .NET
Visual Basic .NET BASICS
Visual Basic.NET Windows Programming
Microsoft Visual Basic 2005: Reloaded Second Edition
Object Orientated Programming using C#
Microsoft Visual Basic 2005 BASICS
Chapter Topics 15.1 Graphical User Interfaces
Chapter 2 – Introduction to the Visual Studio .NET IDE
Variables and Arithmetic Operations
Program and Graphical User Interface Design
Chapter 1: An Introduction to Visual Basic 2015
Using GUI Objects and the Visual Studio IDE
Chapter 3 Fundamentals of Programming in Visual Basic 3
Standard Controls.
Windows Desktop Applications
DB Implementation: MS Access Forms
Visual programming Chapter 3: GUI (Graphical User Interface) Part I
Chapter 2 Visual Basic Interface
Program and Graphical User Interface Design
Visual Basic Properties, Methods and Events
Variables and Arithmetic Operations
Microsoft Windows 2000 Professional
Part A – Doing Your Own Input Validation with Simple VB Tools
Windows Forms Introduction
DB Implementation: MS Access Forms
Chapter 15: GUI Applications & Event-Driven Programming
Based on Murach Chapter 10
6. WinForms 2003 C# GUI - Basics.
Visual C# - GUI and controls - 1
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

GUI Programming Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI

WinForms Another name for traditional, Windows-like GUI applications –vs. WebForms, which are web-based Implemented using FCL –hence portable to any.NET platform

Abstraction FCL acts as a layer of abstraction –separates WinForm app from underlying platform System.Windows.Forms.Form CLR Windows OS instance of FCL class object

Form properties Form properties typically control visual appearance: –AutoScroll –BackgroundImage –ControlBox –FormBorderStyle (sizable?) –Icon –Location –Size –StartPosition –Text (i.e. window's caption) –WindowState (minimized, maximized, normal) Form1 form; form = new Form1(); form.WindowState = FormWindowState.Maximized; form.Show();

Form methods Actions you can perform on a form: –Activate :give this form the focus –Close :close & release associated resources –Hide :hide, but retain resources to show form later –Refresh :redraw –Show :make form visible on the screen, & activate –ShowDialog : show modally form.Hide();. form.Show();

Form events Events you can respond to: –bring up properties window –double-click on event name –Load :occurs just before form is shown for first time –Closing :occurs as form is being closed (ability to cancel) –Closed :occurs as form is definitely being closed –Resize :occurs after user resizes form –Click :occurs when user clicks on form's background –KeyPress : occurs when form has focus & user presses key

Example Ask user before closing form: private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { DialogResult r; r = MessageBox.Show("Do you really want to close?", "MyApp", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (r == DialogResult.No) e.Cancel = true; }

Part 4 Controls…

Controls User-interface objects on the form: –labels –buttons –text boxes –menus –list & combo boxes –option buttons –check boxes –etc.

Abstraction Like forms, controls are based on classes in the FCL: –System.Windows.Forms.Label –System.Windows.Forms.TextBox –System.Windows.Forms.Button –etc. Controls are instances of these classes object

Who creates all these objects? Who is responsible for creating control instances? –code is auto-generated by Visual Studio –when form object is created, controls are then created…

Naming conventions Set control's name via Name property A common naming scheme is based on prefixes: –cmdOK refers to a command button control –lstNames refers to a list box control –txtFirstName refers to a text box control

Labels For static display of text –used to label other things on the form –used to display read-only results Interesting properties: –Text :what user sees –Font :how he/she sees it

Command buttons For the user to click & perform a task Interesting properties: –Text :what user sees –Font :how he/she sees it –Enabled :can it be clicked Interesting events: –Click :occurs when button is "pressed" private void cmdAdd_Click(...) { int i, j, k; i = System.Convert.ToInt32( this.txtNum1.Text ); j = System.Convert.ToInt32( this.txtNum2.Text ); k = i + j; MessageBox.Show( "Sum = " + k.ToString() ); }

Text boxes Most commonly used control! –for displaying text –for data entry Lots of interesting features…

Text box properties Basic properties: –Text :denotes the entire contents of text box (a string) –Modified :has text been modified by user? (True / False) –ReadOnly : set if you want user to view text, but not modify Do you want multi-line text boxes? –MultiLine :True allows multiple lines of text –Lines :array of strings, one for each line in text box –ScrollBars :none, horizontal, vertical, or both

Text box events Interesting events: –Enter, Leave :occurs on change in focus –KeyPress :occurs on ascii keypress –KeyDown, KeyUp :occurs on any key combination –TextChanged :occurs whenever text is modified

Customer[] customers;.. // create & fill array with objects.... // display customers in list box foreach (Customer c in customers) this.listBox1.Items.Add(c); List Boxes Great for displaying / maintaining list of data –list of strings –list of objects (list box calls ToString() to display) // display name of selected customer (if any) Customer c; c = (Customer) this.listBox1.SelectedItem; if (c == null) return; else MessageBox.Show(c.Name);

Summary Forms are the first step in GUI design –each form represents a window on the screen –form designer enables drag-and-drop GUI construction Users interact primarily with form's controls –labels, text boxes, buttons, etc. –implies that GUI programming is control programming