15 building applications with windows forms n.
Skip this Video
Loading SlideShow in 5 Seconds..
15. Building Applications with Windows Forms PowerPoint Presentation
Download Presentation
15. Building Applications with Windows Forms

Loading in 2 Seconds...

play fullscreen
1 / 29

15. Building Applications with Windows Forms - PowerPoint PPT Presentation

  • Uploaded on

15. Building Applications with Windows Forms. Why Use Windows Forms? Structure of Windows Forms Using Windows Forms Using Controls. Code Samples. Why Use Windows Forms?. Accessibility support Visual inheritance Extensible object model Advanced forms design. Rich set of controls

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about '15. Building Applications with Windows Forms' - len-griffin

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
15 building applications with windows forms
15. Building Applications with Windows Forms
  • Why Use Windows Forms?
  • Structure of Windows Forms
  • Using Windows Forms
  • Using Controls

Code Samples

why use windows forms
Why Use Windows Forms?
  • Accessibility support
  • Visual inheritance
  • Extensible object model
  • Advanced forms design
  • Rich set of controls
  • Flat look style
  • Advanced printing support
  • Advanced graphics support – GDI+
structure of windows forms
Structure of Windows Forms
  • Windows Forms Class Hierarchy
  • Using the Windows.Forms.Application Class
  • Examining the Code Behind Windows Forms
windows forms class hierarchy
Windows Forms Class Hierarchy






using the windows forms application class
Using the Windows.Forms.Application Class

Allows the application to continue after the form is closed

static void Main()


frmCustomers f = new frmCustomers();




examining the code behind windows forms
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;

using windows forms
Using Windows Forms
  • Using Form Properties
  • Using Form Methods
  • Using Form Events
  • Handling Events
  • Creating MDI Forms
  • Using Standard Dialog Boxes
using form properties
Using Form Properties
  • DialogResult
  • Font
  • Opacity
  • MaximumSize and MinimumSize
  • TopMost
  • AcceptButton and CancelButton
using form methods
Using Form Methods
  • Close
  • ShowDialog and Show

if blnEndApp = true


this.Close( );


//Create a second form

frmCustomerDetails f = new frmCustomerDetails();

//Show as a dialog box (modal)


//Show as a owned form (non-modal)



using form events
Using Form Events
  • Activated and Deactivate
  • Closing
  • Closed
handling events
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);

creating mdi forms
Creating MDI Forms
  • Creating the parent form
  • Creating child forms
  • Accessing child forms
  • Arranging child forms

this.IsMdiContainer = true;

this.WindowState = FormWindowState.Maximized;

Form2 doc = new Form2( );

doc.MdiParent = this;

doc.Show( );

using standard dialog boxes
Using Standard Dialog Boxes
  • MsgBox
  • MessageBox Class
  • InputBox

if (MsgBox("Continue?", MsgBoxStyle.YesNo +

MsgBoxStyle.Question, "Question") == MsgBoxResult.Yes)

{ ...


if (MessageBox.Show("Continue?", "Question",

MessageBoxButtons.YesNo, MessageBoxIcon.Question)

= DialogResult.Yes)

{ ...


using controls
Using Controls
  • New Controls
  • Using Control Properties
  • Using Control Methods
  • Creating Menus
  • Providing User Help
  • Implementing Drag-and-Drop Functionality
using control properties
Using Control Properties
  • Positioning
    • Anchor
    • Docking
    • Location
  • Text property
using control methods
Using Control Methods
  • BringToFront and SendToBack
  • Focus

Button1.BringToFront( );

Button2.SendToBack( );

TextBox1.Focus( );

TextBox1.SelectAll( );

providing user help
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
implementing drag and drop functionality
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
advanced features overview
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
new controls and components
New Controls and Components
  • FlowLayoutPanel and TableLayoutPanel controls
  • SplitContainer control
  • ToolStrip, MenuStrip, StatusStrip, and ContextMenuStrip controls
  • DataGridView control
  • BindingNavigator control
  • MaskedTextBox control
  • WebBrowser control
new data binding model and features
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
asynchronous programming
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
what is clickonce
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
features and benefits
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
  • 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?
lab 15 building applications with windows forms
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