You are previewing Windows Forms Programming in C#.
O'Reilly logo
Windows Forms Programming in C#

Book Description

Praise for Windows Forms Programming in C#

“Chris may have a strong affinity for semi-colons, but anybody who’s programming Windows Forms needs to read this book.”

     —Brian Randell, Visual Basic Guru and DevelopMentor Instructor

“Chris Sells has done it again. This book has everything a developer needs to know to write serious WinForms applications. Chris leaves no stone unturned in explaining the WinForms programming model and arming developers with the knowledge they need to exploit WinForms to the fullest. And, as if that weren’t enough, Chris’s writing style makes this book a page-turner for geeks. I couldn’t put it down! Until John Grisham gets the .NET religion, you won’t find a better WinForms book anywhere.”

     —Jeff Prosise, co-founder of Wintellect, author of Programming Microsoft .NET

“Chris is clearly *the* expert on web deployment of WinForms. In this book, Chris explains this material clearly and the power of the technology really shows. Unlike other WinForms books, this manuscript takes a more practical approach to the use of programming tools, such as Visual Studio. Sells’s book strikes a nice balance between theory and practice. Windows Forms is an important technology that needs more press. Chris Sells’ book is in great position to be the definitive work on the emerging technology.”

     —Brian Graff, Sr. SW Engineer, PreEmptive Solutions, Inc.

“Chris has written the best WinForms book around. Period.”

     —Pierre Nallet, DevelopMentor Instructor

“Chris does a nice job of presenting the core elements of WinForms complete with many concise samples and graphic depictions of UI features in action. Even more compelling, however, is how Chris anticipates how most developers will want to use these features, and presents techniques and paradigms of usage that will be invaluable for any serious WinForms developer. This book is destined to become dog-eared in the hands anyone building WinForms applications.”

     —Fritz Onion, DevelopMentor instructor and author of Essential ASP.NET

“I don’t want just a description of the WinForms widgets. I can get that online or from other books. What I want is a roadmap for pitfalls to avoid, and innovative solutions for common problems. That is where this book shines.”

     —Johan Ericcson, SW Engineer, Agilent

“This is the definitive book for every Windows Programmer.”

     —Fumiaki Yoshimatsu, Sr. Engineer, Intoferia Corporation

“After browsing through countless books that introduce me to Windows Forms basics, it is refreshing to find a book that dives right into some real hard-core programming. This is, without a doubt the best and most useful C#/WinForms book I have ever read. I would suggest this book to be essential reading for very serious .NET WinForms developer who wants to work smarter instead of harder.”

     —Serge Shimanovsky, Software Developer, Rueters Group PLC

“In this book, Chris Sells discusses how the Windows Forms classes and their supporting infrastructure can be used to write robust and rich smart client applications. If you’re an experienced Windows programmer who has previously used MFC or directly utilized the Win32 API to write such applications, you will find Chris’s direct delivery very appropriate for transferring your knowledge to the managed classes. If you’re a developer with less Windows development experience, you’ll find the treatment of core concepts in application UI programming indispensable.”

     —From the foreword by Mike Blaszczack, Architect, SQL Server Data Warehousing, Microsoft

"I think this book does a great job of hitting a huge number of features—sometimes I forget how much there is to WinForms!"—Chris Anderson, Software Architect, Microsoft Windows Forms team

Programming Windows Forms in C# is the ultimate guide to using the Microsoft .NET forms package. Readers learn how to build smart client applications that take full advantage of both the rich user interface features of the Microsoft Windows operating system and the deployment features of HTML-based applications. Author Chris Sells draws upon his WinForms research and programming experience to provide what the Windows Forms documentation could not: a clear picture of exactly how C# programmers will want to use WinForms.

Well-written and easy to navigate, this book presents the building blocks of WinForms and the best practices for creating stand-alone client applications and front ends to databases and Web services. Readers gain an understanding of the rationale behind aspects of WinForms' design and will find out how to avoid or solve common problems. Figures illustrate WinForms' user interface features and code samples are used throughout the book to demonstrate best practices. All code has been tested with Visual Studio .NET 1.1 and is available at, where readers will also find updates to the book.

This book focuses on the topics readers need to understand in order to build real-world applications. These topics include:

Form layout

  • Multiple top-level windows

  • Non-rectangular windows

  • Accessing data from the middle tier, filesystems, XML, databases, and Web services

  • Classes outside the System.WinForms namespace, including System.Drawing and System.Security

  • Custom drawing

  • Hosting and building controls

  • Design-time integration

  • Data binding

  • Multithreaded user interfaces

  • Deploying WinForms over the Web

  • Moving from MFC

  • Delegates and events

  • Serialization basics

  • Programming Windows Forms in C# is the tutorial for experienced Windows programmers who are serious about mastering Windows Forms.

    Table of Contents

    1. Copyright
    2. Microsoft .NET Development Series
    3. Figures
    4. Tables
    5. Foreword
    6. Preface
    7. Hello, Windows Forms
      1. WinForms from Scratch
      2. Windows Forms in Visual Studio .NET
      3. Arranging Controls
      4. Controls
      5. Application Settings
      6. Resources
      7. Dialogs
      8. Drawing and Printing
      9. Data Binding
      10. Multithreaded User Interfaces
      11. Deployment
      12. Moving from MFC
      13. Where Are We?
    8. Forms
      1. Showing Forms
      2. Form Lifetime
      3. Form Size and Location
      4. Form Adornments
      5. Form Transparency
      6. Form Menus
      7. Child Controls
      8. Layout
      9. Multiple Document Interface
      10. Visual Inheritance
      11. Where Are We?
    9. Dialogs
      1. Standard Dialogs
      2. Styles
      3. Data Exchange
      4. Data Validation
      5. Implementing Help
      6. Where Are We?
    10. Drawing Basics
      1. Drawing to the Screen
      2. Colors
      3. Brushes
      4. Pens
      5. Shapes
      6. Paths
      7. Images
      8. Where Are We?
    11. Drawing Text
      1. Fonts
      2. Strings
      3. Where Are We?
    12. Advanced Drawing
      1. Page Units
      2. Transforms
      3. Regions
      4. Optimized Drawing
      5. Where Are We?
    13. Printing
      1. Print Documents
      2. Print Controllers
      3. Basic Print Events
      4. Margins
      5. Page Settings
      6. Printer Settings
      7. Where Are We?
    14. Controls
      1. Standard Controls
      2. Custom Controls
      3. User Controls
      4. Drag and Drop
      5. Where Are We?
    15. Design-Time Integration
      1. Components
      2. Design-Time Integration Basics
      3. Extender Property Providers
      4. Type Converters
      5. UI Type Editors
      6. Custom Designers
      7. Where Are We?
    16. Resources
      1. Resource Basics
      2. Resource Localization
      3. Where Are We?
    17. Applications and Settings
      1. Applications
      2. Environment
      3. Settings
      4. Where Are We?
    18. Data Sets and Designer Support
      1. Data Sets
      2. Designer Support
      3. Typed Data Sets
      4. Where Are We?
    19. Data Binding and Data Grids
      1. Data Binding
      2. Data Grids
      3. Custom Data Sources
      4. Where Are We?
    20. Multithreaded User Interfaces
      1. Long-Running Operations
      2. Asynchronous Web Services
      3. Where Are We?
    21. Web Deployment
      1. Hosting Controls in Internet Explorer
      2. Code Access Security
      3. No-Touch Deployment
      4. Partially Trusted Assembly Considerations
      5. Increasing Permissions
      6. Authenticode
      7. Where Are We?
    22. Moving from MFC
      1. A Few Words About MFC
      2. MFC Versus WinForms
      3. Genghis
    23. Delegates and Events
      1. Delegates
      2. Events
      3. Happiness in the Universe
    24. Serialization Basics
      1. Streams
      2. Formatters
      3. ISerializable
      4. Data Versioning
    25. Standard WinForms Components and Controls
      1. Components and Controls Defined
      2. Standard Components
      3. Standard Controls
    26. Bibliography