You are previewing Programming Microsoft® Windows® Forms.
O'Reilly logo
Programming Microsoft® Windows® Forms

Book Description

Whether you’re a new or experienced developer, get the focused information you need to streamline application development using Windows Forms and Microsoft .NET Framework 2.0. Award-winning author Charles Petzold illuminates the essential concepts and techniques for exploiting Windows Forms capabilities—offering concise, eloquent instruction as always, along with ample code examples in C#.

Discover how to:

  • Understand the architecture of Windows Forms programs
  • Add familiar Windows controls to your application, such as buttons, scroll bars, and text boxes
  • Create toolbars, menus, and status bars, complete with text and bitmap images
  • Enhance existing controls, combine multiple controls, or create custom controls from scratch
  • Exploit dynamic layout with FlowLayoutPanel
  • Support absolute, proportional, or auto-sized columns and rows with TableLayoutPanel
  • Develop data-bound controls
  • Display tabular data with the new DataGridView control—without writing extensive code
  • PLUS—Build and deploy two real-world Windows Forms applications from the bottom up

Table of Contents

  1. Dedication
  2. Special Upgrade Offer
  3. A Note Regarding Supplemental Files
  4. Introduction
    1. Your Background and Needs
    2. Organization of This Book
    3. System Requirements
    4. Prerelease Software
    5. Technology Updates
    6. Code Samples
    7. Support for This Book
      1. Questions and Comments
      2. The Author’s Web Site
    8. Special Thanks
  5. 1. Creating Applications
    1. Orientation
      1. Programming Tools
      2. The Docs
    2. Development
      1. The Littlest Programs
      2. Visual Studio Projects
      3. References
      4. From Console to Windows
      5. Fixing the Flaws
      6. Events and Event Handlers
      7. Inheriting from Form
      8. Properties and Events in Visual Studio
      9. Children of the Form
      10. Subclassing Controls
      11. Device-Independent Coding
      12. Assembly Information
      13. Dialog Boxes
        1. Modal Dialog Boxes
        2. Modeless Dialog Boxes
      14. DLLs
  6. 2. The Control Cornucopia
    1. Controls in General
      1. Parents and Children
      2. Visibility and Response
      3. Location and Size
      4. Fonts and Color
      5. Keeping Track of Controls
      6. Image Lists
      7. ToolTips
    2. Static (and Not Quite so Static) Controls
      1. GroupBox
      2. Label
      3. LinkLabel
      4. PictureBox
      5. ProgressBar
    3. Push Buttons and Toggles
      1. Button
      2. CheckBox
      3. RadioButton
    4. Scroll Bars
      1. Horizontal and Vertical Scrolls
      2. Track Bars
    5. Text-Editing Controls
      1. MaskedTextBox
      2. TextBox
      3. RichTextBox
    6. List and Combo Boxes
      1. ListBox
      2. CheckedListBox
      3. ComboBox
      4. Up/Down Controls
      5. NumericUpDown
      6. DomainUpDown
    7. Dates and Times
      1. MonthCalendar
      2. DateTimePicker
    8. Tree View and List View
      1. TreeView
      2. ListView
  7. 3. Panels and Dynamic Layout
    1. Approaches to Layout
      1. Layout Headaches
      2. The <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>AutoSize</em></span> Property Property
      3. Panels and Containers
    2. Dock and Anchor
      1. Docking Techniques
      2. Plain Panels
      3. Anchors
    3. Splitters
    4. Padding and Margin
    5. Flow Layout Panel
      1. Docking and Anchoring in Flow Layout
      2. Bye, Bye, <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>GroupBox</em></span>
    6. Table Layout Panel
      1. Automatic Table Growth
      2. Cell Positions
      3. Column and Row Styles
      4. <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>Dock</em></span> and and <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>Anchor</em></span>
      5. Column and Row Spans
      6. Case Study: Font Dialog
    7. Testing Your Layouts
  8. 4. Custom Controls
    1. Enhancing Existing Controls
      1. Overriding Methods
      2. Adding New Properties
      3. Control Paint Jobs
    2. Combining Existing Controls
      1. The Sheer Pleasure of Autoscroll
    3. Controls from Scratch
      1. An Interactive Ruler
      2. Color Selection
  9. 5. Cruisin’ the Strip
    1. Menus and Menu Items
      1. Menu Items in General
      2. Assembling the Menu
      3. Fields or Fishing
      4. Controls, Items, and Owners
      5. Checking and Unchecking
      6. Adding Images
      7. Custom Menu Items
      8. Context Menus
    2. Tool Strips and Their Components
      1. Tool Strip Buttons
      2. Controls as <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>ToolStrip</em></span> Items Items
      3. A Text-Formatting <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>ToolStrip</em></span>
      4. Handling Multiple Tool Strips
    3. Status Strips
      1. Status Labels
  10. 6. Data Binding and Data Views
    1. Linking Controls and Data
      1. How It Works
      2. Control Bites Data
      3. ColorScroll Revisited
      4. The <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>ComboBox</em></span> Difference Difference
    2. Entry-Level Data Entry
      1. The Traditional Approach
      2. XML Serialization
      3. Not Quite Bindable
      4. The <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>BindingSource</em></span> Intermediary Intermediary
      5. Navigating the Data
      6. Direct to Data
    3. The <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>DataGridView</em></span> Control Control
      1. <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>DataGridView</em></span> and Text and Text
      2. The Class Hierarchy
      3. Expanding Our Data Horizons
      4. Saving to XML
      5. Validation and Initialization
      6. Implementing a Calendar Column
      7. <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>DataGridView</em></span> and Data Binding and Data Binding
  11. 7. Two Real Applications
    1. Case Study 1: ControlExplorer
      1. The <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="emphasis"><em>Control</em></span> Class Hierarchy Class Hierarchy
      2. Read-Only Properties
      3. Dynamic Event Trapping
      4. Wrapping It Up
      5. ClickOnce Installation
      6. Security Issues
      7. Publishing the Application
    2. Case Study 2: MdiBrowser
      1. The Multiple Document Interface
      2. Solution and Project
      3. Favorites and Settings
      4. The Child Window
      5. The Application Form
      6. The File Menu
      7. The View Menu
      8. The Favorites Menu
      9. The Window Menu
      10. The Help Menu
      11. The Two Tool Strips
      12. HTML Help
  12. A. Charles Petzold
  13. Index
  14. About the Author
  15. Special Upgrade Offer
  16. Copyright