Week 2: WINDOWS PROGRAMMING Chapter 15 in “Beginning Visual C# 2010” ebook Chapter 4 in “”MCTS_Self-Paced_Training_Kit” ebook.

Slides:



Advertisements
Similar presentations
VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
Advertisements

Chapter 1: An Introduction to Visual Basic 2012
© by Pearson Education, Inc. All Rights Reserved.
© by Pearson Education, Inc. All Rights Reserved. continued …
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.
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.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
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.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
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,
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Chapter 1 Mr. Wangler.
Microsoft Visual Basic 2005: Reloaded Second Edition
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
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,
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 - Graphical User Interface Concepts: Part.
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 Two Creating a First Project in Visual Basic.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
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.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Menus Menus provide groups of related commands for windows applications Menu, menu items, submenus A menu item that contains a submenu is considered to.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
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.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
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.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
 2007 Pearson Education, Inc. All rights reserved Introduction to the Visual Basic Express 2005 IDE.
 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.
2-1 Chapter 2 Using VB.NET to Create a First Solution.
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.
Graphical User Interface Concepts - Part 1 Session 08 Mata kuliah: M0874 – Programming II Tahun: 2010.
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Graphical User Interface
Object Orientated Programming using C#
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
Graphical User Interface Concepts: Part I
Chapter 2 – Introduction to the Visual Studio .NET IDE
The University of Texas – Pan American
Building an Application in the Visual Basic .NET Environment
Visual Studio.
Week 2: WINDOWS PROGRAMMING
Presentation transcript:

Week 2: WINDOWS PROGRAMMING Chapter 15 in “Beginning Visual C# 2010” ebook Chapter 4 in “”MCTS_Self-Paced_Training_Kit” ebook

Week 2: WINDOWS PROGRAMMING Working with Windows Forms

CONTROLS When you work with Windows Forms, you are working with the System.Windows.Forms namespace Most controls in.NET derive from the System.Windows.Forms.Control class Many of these classes are themselves base classes for other controls, as is the case with the Label and TextBoxBase classes Windows Programming 1 Basic Windows Programming Slide 3

CONTROLS Windows Programming 1 Basic Windows Programming Slide 4

Properties Common Control Class Properties Windows Programming 1 Basic Windows Programming Slide 5

Properties Common Control Class Properties Windows Programming 1 Basic Windows Programming Slide 6

Adding Controls to a Windows Form Adding Controls by Using the Windows Forms Designer Adding Controls Programmatically Windows Programming 1 Basic Windows Programming Slide 7

Adding Controls Programmatically 1. Create a private variable to represent each of the controls you want to place on the form 2. In the form, place code to instantiate each control and to customize each control, using its properties, methods, or events. 3. Add each control to the forms control collection. Windows Programming 1 Basic Windows Programming Slide 8

Exam (page 113) Windows Programming 1 Basic Windows Programming Slide 9

Handling Control Events Add controls to a Windows form. Set properties on controls. Load controls dynamically. Write code to handle control events and add the code to a control. Windows Programming 1 Basic Windows Programming Slide 10

Handling Control Events_Ex Windows Programming 1 Basic Windows Programming Slide 11

Windows Programming 1 Basic Windows Programming Slide 12 HANDLING CONTROL EVENTS

Windows Programming 1 Basic Windows Programming Slide 13

Windows Programming 1 Chapter 15:Basic Windows Programming Slide 14 HANDLING CONTROL EVENTS

Windows Programming 1 Chapter 15:Basic Windows Programming Slide 15 HANDLING CONTROL EVENTS

COMMON WINDOWS FORMS CONTROLS Windows Programming 1 Basic Windows Programming Slide 16

Naming Rules Always use standard names for objects No spaces or punctuation marks 3 letter lowercase prefix identifies control type Button-btn Label-lbl Form-frm If multiple words capitalize 1st letter of each word Each object name is an identifier Can contain letters, digits, and underscores (_) Cannot start with digits Can start with the at symbol Windows Programming 1 Basic Windows Programming Slide 17

Recommended Naming Object ClassPrefixExample Form frm frmDataEntry Button btn btnExit TextBox txt txtPaymentAmount Label lbl lblTotal Radio Button rad radBold CheckBox chk chkPrintSummary PictureBox pic picLandscape ComboBox cbo cboBookList ListBox lst lstIndegredients GroupBox grb grbColor Windows Programming 1 Basic Windows Programming Slide 18

Windows Forms Windows Forms is the basic building block of the UI It provides a container that hosts controls and menus and enables you to present an application in a familiar and consistent fashion You can add and configure additional forms at design time, or you can create instances of predesigned forms in code at run time. Windows Programming 1 Basic Windows Programming Slide 19

Windows Forms Some Properties of the Form Class Windows Programming 1 Basic Windows Programming Slide 20

Windows Forms Some Properties of the Form Class Windows Programming 1 Basic Windows Programming Slide 21

Windows Forms Some Properties of the Form Class Windows Programming 1 Basic Windows Programming Slide 22

Setting the Title of the Form To change the title of a form at run time, set the Text property of the form in code, as shown in the following code: Windows Programming 1 Basic Windows Programming Slide 23

Setting the Border Style of the Form Windows Programming 1 Basic Windows Programming Slide 24

Specifying the Startup Location of the Form Windows Programming 1 Basic Windows Programming Slide 25

Keeping a Form on Top of the User Interface TopMost = True FormBorderStyle = None; StartPosition = CenterToScreen; Windows Programming 1 Basic Windows Programming Slide 26 Module2- 21

Opacity and Transparency in Forms The Opacity property to create striking visual effects in your form Values between 0 percent and 100 percent result in a partially transparent form Windows Programming 1 Basic Windows Programming Slide 27

Setting the Startup Form 1. In Solution Explorer, double-click Program.cs to view the code. The code window opens. 2. Locate the Main method and then locate the line that reads: Application.Run(new Form()); where Form represents the name of the form that is currently the startup form. 3. Change Form to the name of the form you want to set as the startup form. Windows Programming 1 Basic Windows Programming Slide 28

Control Properties and Layout Common properties Derive from class Control Text property Specifies the text that appears on a control Focus method Transfers the focus to a control Becomes active control Enable property Indicate a control’s accessibility Windows Programming 1 Basic Windows Programming Slide 29

Control Properties and Layout Visibility control Hide control from user Anchor property Anchoring control to specific location (corner) Unanchored control moves relative to the position Docking allows control to spread itself along and entire side Both options refer to the parent container Windows Programming 1 Basic Windows Programming Slide 30

Control Properties and Layout Fig Anchoring demonstration. Constant distance to left and top sides Before resize After resize Windows Programming 1 Basic Windows Programming Slide 31

Control Properties and Layout Fig Manipulating the Anchor property of a control. Darkened bar indicates to which wall control is anchored Click down-arrow in Anchor property to display anchoring window Windows Programming 1 Basic Windows Programming Slide 32

Control Properties and Layout Fig Docking demonstration. Control expands along top portion of the form Windows Programming 1 Basic Windows Programming Slide 33

Control Properties and Layout Windows Programming 1 Basic Windows Programming Slide 34

Labels and LinkLabel controls Labels : The standard Windows label LinkLabel: A label similar to the standard one but that presents itself as an Internet link (a hyperlink) You don’t need to add event handling code for a standard Label Some extra code is needed to enable users clicking it to go to the target of the LinkLabel Windows Programming 1 Basic Windows Programming Slide 35

Common Label Control Properties Windows Programming 1 Basic Windows Programming Slide 36

Common Label Control Properties Windows Programming 1 Basic Windows Programming Slide 37

Windows Programming 1 Chapter 15:Basic Windows Programming Slide 38 Button Control

Lable –Textbox – Button Control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 39

LinkLable - Demo Windows Programming 1 Chapter 15:Basic Windows Programming Slide 40

Windows Programming 1 Chapter 15:Basic Windows Programming Slide 41 LinkLable - Demo

TextBoxes and RichTextBox The.NET Framework comes with two basic controls to take text input from users: TextBox and RichTextBox. Both controls are derived from a base class called TextBoxBase, which itself is derived from Control. Windows Programming 1 Basic Windows Programming Slide 42

Common TextBox Control Properties Windows Programming 1 Basic Windows Programming Slide 43

Common TextBox Control Properties Windows Programming 1 Basic Windows Programming Slide 44

THE RICHTEXTBOX CONTROL Like the normal TextBox, the RichTextBox control is derived from TextBoxBase Whereas a TextBox is commonly used for the purpose of obtaining short text strings from the user The RichTextBox is used to display and enter formatted text (e.g., bold, underline, and italic). It does so using a standard for formatted text called Rich Text Format, or RTF. Windows Programming 1 Basic Windows Programming Slide 45

Common RichTextBox Control Properties Windows Programming 1 Basic Windows Programming Slide 46

Common RichTextBox Control Properties Windows Programming 1 Basic Windows Programming Slide 47

RichTextbox - demo Windows Programming 1 Chapter 15:Basic Windows Programming Slide 48

RichTextbox - demo Windows Programming 1 Chapter 15:Basic Windows Programming Slide 49

Windows Programming 1 Chapter 15:Basic Windows Programming Slide 50

Week 2: WINDOWS PROGRAMMING Controls for displaying pictures

The PictureBox Control The PictureBox control is the basic control used for displaying images in the user interface, and it can display pictures in a variety of formats, including.bmp,.jpg,.gif, metafiles, and icons. Windows Programming 1 Basic Windows Programming Slide 52

The PictureBox Control Windows Programming 1 Basic Windows Programming Slide 53

The PictureBox Control At run time, you can set the Image property to an instance of an image, as shown in the following example: Windows Programming 1 Basic Windows Programming Slide 54

Picturebox - demo Windows Programming 1 Chapter 15:Basic Windows Programming Slide 55 Module 2- 6

Picturebox - demo Windows Programming 1 Chapter 15:Basic Windows Programming Slide 56

Picturebox - demo Windows Programming 1 Chapter 15:Basic Windows Programming Slide 57 Module 2- 11

Picturebox - demo Windows Programming 1 Chapter 15:Basic Windows Programming Slide 58