1 15. Building Applications with Windows Forms Why Use Windows Forms? Structure of Windows Forms Using Windows Forms Using Controls Code Samples.

Slides:



Advertisements
Similar presentations
Module 1: Creating an Application by Using Windows Presentation Foundation Overview of WPF Creating a Simple WPF Application Handling Events and Commands.
Advertisements

Getting the Most From Visual Basic 2005 Jay Roxe Lead Product Manager Visual Studio.
 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
DEV392: Extending SharePoint Products And Technologies Through Web Parts And ASP.NET Clint Covington, Program Manager Data And Developer Services - Office.
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
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.
Advanced Object-Oriented Programming Features
Windows Forms in Visual Studio 2005: An in-depth look at key features Name: Mike Henderlight Title: Program Manager.
Create Windows ® Applications with.NET Allan Knudsen.NET Developer Evangelist Microsoft.
What’s New for Smart Client Developers in Visual Studio 2005? Mike Pelton Systems Engineer Microsoft Ltd
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
Visual Basic 2005 and Windows Forms 2.0 Enhancements Tyler Whitney Microsoft, Corp.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
Event-based Programming Roger Crawfis. Window-based programming Most modern desktop systems are window-based. Non-window based environment Window based.
Windows Forms in Visual Studio 2005: An Overview Saurabh Pant Program Manager Microsoft Corporation.
CHAPTER 6 Loop Structures.
Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library.
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Microsoft Confidential Office as a Development Platform Tim Heuer
Using the Actions Pane, Host Controls, and Smart Tags
Module 11 Control Customization. Module Overview Overview of Control Authoring Creating Controls Managing Control Appearance by Using Visual States Integrating.
Windows Presentation Foundation. Agenda Introduction Developing Applications WPF and WF interoperability Custom Controls Styles and Templates Data Binding.
Week 2: WINDOWS PROGRAMMING Chapter 15 in “Beginning Visual C# 2010” ebook Chapter 4 in “”MCTS_Self-Paced_Training_Kit” ebook.
Virtual techdays INDIA │ Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.
Lecture Set 3 Introduction to Visual Basic Concepts Part C – Design Mode Properties In-Depth Look at Common Features of Controls.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
Dr Dat Tran - Week 4 Lecture Notes 1 ToolStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
Windows Forms: Harnessing The Power And Flexibility Of Windows Forms 2.0 Erick Ellis PRS402 Program Manager.NET Client Microsoft Corporation.
Windows Forms in Visual Studio 2005: An Overview Name: Joe Stegman Title: Lead Program Manager Session code.
Fundamentals of.NET NYU-SCPS. Session 7 MS Certification Exams in brief MS Certification Exams in brief Custom Attributes Custom Attributes More on Collections.
Create Windows ® Applications with.NET Carlotta Eaton ( Associate Professor of IST New River Community College Slides by Microsoft.
Windows Forms in Visual Studio 2005 Mike Pelton Systems Engineer Microsoft Ltd
1 Chapter Nine Using GUI Objects and the Visual Studio IDE.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
Module 1 Window Forms – Basic, Grouping and Graphic controls 1.
Dr Dat Tran - Week 2 Lecture Notes 1 Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences & Engineering.
Making the Most of WinForms 2.0 Data Binding Rajiv Sodhi Microsoft India.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Windows Forms in Visual Studio 2005: An in-depth look at key features Name: Joe Stegman Title: Lead Program Manager Session code.
What’s New in Windows Forms 2.0 Stephen Turner Software Design Engineer
Understanding Desktop Applications Lesson 5. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Windows Forms Applications Understand.
1 Visual Basic “Whidbey”: RAD for the Visual Basic Developer Jay Schmelzer and Shamez Rajan Program Manager Microsoft Corporation Jay Schmelzer and Shamez.
Graphical User Interface Components Version 1.1. Obectives Students should understand how to use these basic Form components to create a Graphical User.
Understand Databound Controls Windows Development Fundamentals LESSON 4.2A.
Appendix A: Windows Forms. 2 Overview Describe the structure of a Windows Forms application –application entry point –forms –components and controls Introduce.
Understanding Desktop Applications Lesson 5. Understanding Windows Forms Applications Windows Forms applications are smart client applications consisting.
DEV221 Windows Forms in Visual Studio 2005: An Overview Saurabh Pant Program Manager Microsoft Corporation.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.
Dr. Abraham Professor UTPA Graphical User Interface.
The New User Interface MEDITECH Training & Education.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Visual Basic 2010 How to Program
Chapter 2 – Introduction to the Visual Studio .NET IDE
Files.
Using GUI Objects and the Visual Studio IDE
Understand Windows Forms Applications and Console-based Applications
Creating a Windows Forms User Interface
Lecture Set 11 Creating and Using Classes
6. WinForms 2003 C# GUI - Basics.
Windows Forms in Visual Studio 2005: An in-depth look at key features
Windows Forms in Visual Studio 2005: An Overview
Presentation transcript:

1 15. Building Applications with Windows Forms Why Use Windows Forms? Structure of Windows Forms Using Windows Forms Using Controls Code Samples

2 Why Use Windows Forms? Rich set of controls Flat look style Advanced printing support Advanced graphics support – GDI+ Accessibility support Visual inheritance Extensible object model Advanced forms design

3 Structure of Windows Forms Windows Forms Class Hierarchy Using the Windows.Forms.Application Class Examining the Code Behind Windows Forms

4 Windows Forms Class Hierarchy Control ContainerControl Form UserControl ScrollableControl

5 Using the Windows.Forms.Application Class static void Main() { frmCustomers f = new frmCustomers(); f.Show(); Application.Run(); } Allows the application to continue after the form is closed

6 Examining the Code Behind Windows Forms Imports  To alias namespaces in external assemblies Class  Inherits from System.Windows.Forms.Form  Constructor – public frmCustomers()  Initializer – private void InitializeComponent()  Destructor – protected override void Dispose( … ) using Winforms = System.Windows.Forms;

7 Using Windows Forms Using Form Properties Using Form Methods Using Form Events Handling Events Creating MDI Forms Using Standard Dialog Boxes

8 Using Form Properties DialogResult Font Opacity MaximumSize and MinimumSize TopMost AcceptButton and CancelButton

9 Using Form Methods Close ShowDialog and Show if blnEndApp = true { this.Close( ); } if blnEndApp = true { this.Close( ); } //Create a second form frmCustomerDetails f = new frmCustomerDetails(); //Show as a dialog box (modal) //f.ShowDialog(); //Show as a owned form (non-modal) this.AddOwnedForm(f); f.Show(); //Create a second form frmCustomerDetails f = new frmCustomerDetails(); //Show as a dialog box (modal) //f.ShowDialog(); //Show as a owned form (non-modal) this.AddOwnedForm(f); f.Show();

10 Using Form Events Activated and Deactivate Closing Closed

11 Handling Events Handling multiple events with one procedure this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); this.btnEdit.Click += new System.EventHandler(this.btnAdd_Click); this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); this.btnEdit.Click += new System.EventHandler(this.btnAdd_Click);

12 Creating MDI Forms Creating the parent form Creating child forms Accessing child forms Arranging child forms this.IsMdiContainer = true; this.WindowState = FormWindowState.Maximized; this.IsMdiContainer = true; this.WindowState = FormWindowState.Maximized; Form2 doc = new Form2( ); doc.MdiParent = this; doc.Show( ); Form2 doc = new Form2( ); doc.MdiParent = this; doc.Show( );

13 Using Standard Dialog Boxes MsgBox MessageBox Class InputBox if (MsgBox("Continue?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Question") == MsgBoxResult.Yes) {... } if (MsgBox("Continue?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Question") == MsgBoxResult.Yes) {... } if (MessageBox.Show("Continue?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes) {... } if (MessageBox.Show("Continue?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes) {... }

14 Demonstration: Manipulating Windows Forms

15 Using Controls New Controls Using Control Properties Using Control Methods Creating Menus Providing User Help Implementing Drag-and-Drop Functionality

16 Using Control Properties Positioning  Anchor  Docking  Location Text property

17 Using Control Methods BringToFront and SendToBack Focus TextBox1.Focus( ); TextBox1.SelectAll( ); TextBox1.Focus( ); TextBox1.SelectAll( ); Button1.BringToFront( ); Button2.SendToBack( ); Button1.BringToFront( ); Button2.SendToBack( );

18 Providing User Help ErrorProvider control  Error icon appears next to control, and message appears like a ToolTip when mouse pauses over icon  Used mainly for data binding HelpProvider control  Points to.chm,.hlp, or.html Help file  Controls provide Help information by means of HelpString or HelpTopic properties

19 Demonstration: Using Controls

20 Implementing Drag-and-Drop Functionality Starting the process  Use the DoDragDrop method in the MouseDown event of the originating control Changing the drag icon  Set the AllowDrop property of the receiving control to True  Set the Effect property of the DragEventsArg in the DragOver event of the receiving control Dropping the data  Use the Data.GetData method to access the data

21 Demonstration: Implementing Drag-and-Drop Functionality

22 Advanced Features Overview Enhanced Design-Time Support New Controls and Components New Data-Binding Model and Features Asynchronous Programming Other Significant New Features Demonstration: RAD Data Binding What Is ClickOnce? Features and Benefits

23 New Controls and Components FlowLayoutPanel and TableLayoutPanel controls SplitContainer control ToolStrip, MenuStrip, StatusStrip, and ContextMenuStrip controls DataGridView control BindingNavigator control MaskedTextBox control WebBrowser control

24 New Data-Binding Model and Features BindingSource component  Layer of indirection/abstraction between controls and data source  Can act as strongly typed data source  Interoperates closely with BindingNavigator and DataGridView controls Data components (concept-not class/component)  Building blocks of typed DataSet  Consist of DataTables, TableAdapters, TableAdapter queries  Create/edit using DataSet Designer Data sources (concept-not class/component)  Simplified management of data sources  Enable drag-and-drop creation of data-bound forms Smart tags

25 Asynchronous Programming BackgroundWorker component  DoWork, RunWorkerCompleted, ProgressChanged events  RunWorkerAsync, CancelAsync, ReportProgress methods Asynchronous Pattern for Components  Used by.NET Framework components with long-running methods  PictureBox has Load and LoadAsync methods, and a LoadCompleted event

26 What is ClickOnce? ClickOnce is a new application deployment technology It makes deploying Windows applications as easy as deploying Web applications Application updates are easy to administer

27 Features and Benefits ClickOnce applications are low impact  No administrative rights are required on the client machine Deployment is through Web servers, CDs, or file systems Applications can be installed on the client machine or can run remotely ClickOnce applications execute in a secure environment Visual Studio provides a rich set of support features for publishing ClickOnce applications Prerequisite software can be installed alongside the application installation

28 Review Why Use Windows Forms? Structure of Windows Forms Using Windows Forms Windows Forms Inheritance Enhanced Design-Time Support New Controls and Components New Data-Binding Model and Features Asynchronous Programming What Is ClickOnce?

29 Lab 15: Building Applications with Windows Forms Exercise 1: Using the layout properties of the controls and form Exercise 2: adding a ToolStrip and a ToolTip control Exercise 3: Opening forms and using the new container controls & provider controls