Windows Forms 2.0 Programming / Edition 2

Paperback (Print)
Rent from
(Save 59%)
Est. Return Date: 05/29/2015
Buy Used
Buy Used from
(Save 41%)
Item is in good condition but packaging may have signs of shelf wear/aging or torn packaging.
Condition: Used – Good details
Used and New from Other Sellers
Used and New from Other Sellers
from $1.99
Usually ships in 1-2 business days
(Save 97%)
Other sellers (Paperback)
  • All (20) from $1.99   
  • New (8) from $33.22   
  • Used (12) from $1.99   


“Some books are different-the content can't be Googled from the Internet, the authors have real-life experiences to share, the code can be used in real-world projects. This is one of those books.”

–Neal Myrddin, Independent Developer

“Chris and Michael nail the soul of Windows Forms 2.0. This book provides an insightful view into the design of Windows Forms and the integration of new 2.0 features. It is just as applicable for the first-time Windows Forms programmer as the seasoned line of business developer. The ‘What’s New in 2.0’ appendix is worth the price of admission alone.”

–Mike Harsh, Windows Forms Program Manager, Microsoft, Inc.

“This book takes an amazingly broad and deep technology, and breaks it into manageable pieces that are easily consumed. You cannot survive building a complex WinForms application without this book.”

–Ryan Dorrell, Chief Technology Officer, AgileThought

Windows Forms 2.0 Programming offers something for every .NET developer. Experienced developers will appreciate the in-depth coverage of new 2.0 features, including the most comprehensive coverage of ClickOnce deployment, multithreading, and the new designer integration found anywhere. Developers new to Winforms programming will appreciate the coverage of the fundamentals all Winforms developers need to know. Whether you’re an experienced WinForms developer or just beginning, you need this book.”

–Fritz Onion, cofounder of Pluralsight, author of Essential ASP.NET, and ASP.NET MVP

“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. All of us who found the first edition of this book to be an indispensible part of our reference library will appreciate this updated edition that describes WinForms 2.0.”

–Johan Ericsson, Software Engineer, Agilent Technologies

“The books Chris Sells writes are always insightful and this newest addition is no different. This book in particular is for those who want to understand not just the flashy surface of Windows Forms 2.0, but also how it fits into the .NET environment. Readers will have this book at their desks, not stuck on their shelves, for quite a long time.”

–Yoshimatsu Fumiaki, Software Engineer based in Tokyo Japan

“Chris and Mike have done an excellent job presenting the information you need to be successful with Windows Forms.”

–Jessica Fosler, Dev Tech Lead, Microsoft

“This book is the ‘must have’ teaching and reference book for WinForms 2.0.”

–Jim Rittenhouse, Senior Software Engineer, Siemens

Windows Forms 2.0 Programming is the successor to the highly praised Windows Forms Programming in C#. This edition has been significantly updated to amalgamate the sheer mass of new and improved support that is encompassed by Windows Forms 2.0, the .NET Framework 2.0, and Visual Studio 2005. This is the one book developers need in order to learn how to build and deploy leading-edge Windows Forms 2.0 applications.

Readers will gain a deep understanding from Sells and Weinhardt’s practical, well-balanced approach to the subject and clear code samples.

• Windows Forms 2.0 fundamentals, including forms, dialogs, data validation, help, controls, components, and rendering

• Static and dynamic layout, snap lines, HTML-style flow and table layout, automatic resizing, and automatic cross-DPI scaling

• Office 2003-style tool strip control coverage, including dynamic layout and custom rendering

• Design-time integration with the Visual Studio 2005 Properties Window and Smart Tags

• Resource management, strongly typed resources, and internationalization considerations

• Strongly typed application and user settings

• SDI, MDI, Single Instancing, Multiple-Instance SDI, Single-Instance MDI, database-centric, and document-centric applications

• Databinding data-source management, drag-and-drop databinding, the BindingSource, the BindingNavigator, and applied databinding

• Events, delegates, multithreaded UIs, long-running operations, simplified multithreading with the BackgroundWorker, and asynchronous web service calls

• ClickOnce application development publishing, shell integration, and partial trust security

• Best practices for developers transitioning from Windows Forms 1.0 and MFC

Read More Show Less

Product Details

  • ISBN-13: 9780321267962
  • Publisher: Addison-Wesley
  • Publication date: 5/5/2006
  • Series: Microsoft .NET Development Series
  • Edition description: REV
  • Edition number: 2
  • Pages: 1296
  • Sales rank: 1,524,691
  • Product dimensions: 7.00 (w) x 9.10 (h) x 2.20 (d)

Meet the Author

Chris Sells is a program manager for the Connected Systems Division. He’s written several books, including Programming Windows Presentation Foundation (O’Reilly), Windows Forms Programming in C# (Addison-Wesley), and ATL Internals (Addison-Wesley). In his free time, Chris hosts various conferences and makes a pest of himself on Microsoft internal product team discussion lists. More information about Chris–and his various projects–is available at

Michael Weinhardt is a programmer/writer at Microsoft, working on the Windows Client SDK. Michael has coauthored a variety of articles with Chris, contributed to the “Wonders of Windows Forms” column at MSDN Online, reviewed several Windows technology books, and generally loves communicating the whys and wherefores of technology to his peers. Michael is sure that his parents attribute his fascination in technology to their purchase of an Amiga 1000 in the mid-80s. They would be right.

Read More Show Less

Table of Contents

About the Authors xxv

Foreword xxvii

Preface xxxi

Chapter 1 Hello, Windows Forms 1

Chapter 2 Forms 41

Chapter 3 Dialogs 99

Chapter 4 Layout 137

Chapter 5 Drawing Basics 179

Chapter 6 Drawing Text 231

Chapter 7 Advanced Drawing 265

Chapter 8 Printing 291

Chapter 9 Components 327

Chapter 10 Controls 353

Chapter 11 Design-Time Integration: The Properties Window 399

Chapter 12 Design-Time Integration: Designers and Smart Tags 453

Chapter 13 Resources 505

Chapter 14 Applications 549

Chapter 15 Settings 579

Chapter 16 Data Binding Basics 629

Chapter 17 Applied Data Binding 681

Chapter 18 Multithreaded User Interfaces 737

Chapter 19 ClickOnce Deployment 775

Appendix A What’s New in Windows Forms 2.0 829

Appendix C Delegates and Events 867

Appendix D Component and Control Survey 881

Appendix E Drag and Drop 901

Appendix F Document Management 927

Bibliography 957

Index 961

Read More Show Less



Windows 1.0 programmers had a straightforward life. They had almost no choices about how to do things; either there was an application programming interface (API), or there wasn’t, and most of the time there wasn’t. This meant that developers had to build almost everything by hand. At the time, this wasn’t a problem. All Windows programmers had the same limitations, so everyone’s apps more or less operated with the same limited set of functionality.

A modern Windows developer, on the other hand, is inundated with choices. The invention of the web alone gives us static Hypertext Markup Language (HTML), server-based user interface (UI) interaction via ASP.NET, and client-side UI interaction via ActiveX controls or AJAX (to name a few).1 On the client side, we have native frameworks like Microsoft Foundation Classes (MFC), Active Template Library (ATL), and the next-generation managed framework known as the Windows Presentation Foundation (WPF is part of WinFX, the follow-on to the .NET Framework). How does a developer choose? Where does Windows Forms 2.0, the topic of this book, fit into this pantheon?

1 AJAX stands for Asynchronous JavaScript and XML, as defined by Jesse James Garrett, “Ajax: A New Approach to Web Applications,” (

Client technologies on Windows provide a range of reach and richness in inverse proportion to each other. Reach is the ability of a user interface (UI) to work across operating systems, whereas richness is the ability for a UI to take advantage of theoperating system on which it runs. So even though static HTML works almost everywhere, to the extent that your HTML uses client-side JScript, reach is diminished for browsers that don’t support the scripting constructs being used. Even further down the reach scale are ActiveX controls, which work only on Windows but allow full access to its richness.2

2 At one point, the Component Object Model (COM) and ActiveX were made to work across platforms, but they have long since been relegated to Windows only.

At the other extreme we have WPF, a completely new managed framework built on top of DirectX. WPF encompasses documents, layout, animation, 2-D, 3-D, text, and graphics primitives in a single, cohesive whole. This framework provides the richest client technology that Microsoft has ever built, and it takes maximum advantage of the platform on which it runs, including any hardware 3-D graphics acceleration that may be available. However, at the time of this writing, WPF has not yet shipped and works only under Windows XP, Windows Server 2003, and Windows Vista.3

3 WinFX (which inclues WPF) and Windows Vista are scheduled to ship in 2006.

Where does that leave Windows Forms 2.0? It doesn’t quite offer the richness of WPF, but it’s far richer than the HTML-based technologies. Windows Forms 2.0 also is much richer than Windows Forms 1.0, with greatly enhanced support for flexible layout, modern menu strip and tool strip controls, data binding, multithreading, typed resources and settings, and, most importantly, ClickOnce deployment.

With ClickOnce, for the first time, users can deploy Windows applications as easily as web applications. Even better, ClickOnce allows Windows applications to be installed locally, integrated with the Start menu, and accessed even if no network connection is available. These options are not available for users of Web applications.

So Windows Forms 2.0 is high on the richness scale, but what about the reach scale? Unlike web applications, Windows Forms requires that users’ machines operate on Windows, specifically Windows 98 or later for PCs. However, it also supports other devices, such as Pocket PCs or Smartphones, via the .NET Compact Framework. This means that you can write a Windows Forms 2.0 application and run it on your Windows smartphone.

Based on this level of richness and reach, what kinds of applications should you build with Windows Forms? As it turns out, folks have used Windows Forms to build almost every kind of application, including productivity applications, utilities, enterprise tools, and more—even games. Windows Forms can be used to build smaller things, such as Microsoft’s own internal human resources application (called HeadTrax), or larger things, such as most of the UI enhancements that have been built on top of Visual Studio since the 2002 edition. This range of applications can be built because of Windows Forms’ range of features and tools, its reach, and, as of this version, the maturity of the implementation based on community usage and feedback.

In fact, the .NET developer community has embraced Windows Forms to a degree that defies the early .NET focus on web-based applications. Based on talking to my friends in the training industry and on the sales of the first edition of this book, I conclude that a large and growing number of developers write Windows Forms applications. It’s for those developers that we’ve written this book.

Who Should Read This Book?

When writing this book, we wanted to provide real-world Windows Forms coverage for programmers who’ve programmed in .NET—and those who haven’t. To that end, we briefly introduce core .NET topics as they come up. However, we don’t pretend to cover the .NET Framework completely. It’s too large a topic. Instead, when we think more information would be useful, we reference another work that provides the full details. In particular, you’ll find that we’ve referenced Essential .NET, by Don Box, with Chris Sells, a great deal, making it a good companion to this book. In the same category, we also recommend Advanced .NET Remoting, by Ingo Rammer, and Applied Microsoft .NET Framework Programming, by Jeffrey Richter. (For more details on these books, see the Bibliography.)

One core .NET topic is of special importance to Windows Forms programmers, and we cover it in more detail in Appendix C: Delegates and Events. This coverage is particularly important if you’re new to .NET, although we don’t recommend diving into that topic until you’ve got a Windows Forms-specific frame of reference (which is provided about one-third of the way through Chapter 1: Hello, Windows Forms).

Also of particular importance to former (or soon-to-be former) MFC programmers, we’ve provided Appendix B: Moving from MFC, and Appendix F: Document Management. Although Windows Forms doesn’t provide all the features of MFC, we’ve worked hard on the material and code samples in this book to plug most of the gaps.

One other note: Many years ago, one of the authors wrote his first five-day training course. The topic, Windows 95, included a few hours of coverage on the new controls: what they looked like, what their properties, methods, and events were, and how to program against them. Those hours seemed like days for everyone involved. The details of a particular control are interesting only when you’re putting it to use, and when that time comes, the control-specific documentation and Visual Studio’s IntelliSense help support do a marvelous job of giving you the information you need.

To that end, this book covers none of the standard controls completely. Instead, when a control is interesting in the context of the current topic—such as the DataGridView control in Chapter 17: Applied Data Binding—we cover that control appropriately. Also, to give you a list of all the components and controls and to introduce you to each one’s major functionality, Appendix D: Component and Control Survey provides a list of the standard controls and components. We wouldn’t think of wasting your time by attempting to be more thorough than the reference documentation that comes with the .NET Framework software development kit (SDK) and Visual Studio 2005. Instead, this book focuses on the real-world scenarios that aren’t covered in detail elsewhere. Finally, to help you understand the differences between components and controls and how to build both, we’ve provided Chapter 9: Components and Chapter 10: Controls.


If you’ve decided to take the plunge with this book, we’d like to thank you for your faith and express our hope that we live up to it. To aid you in reading the text, we want to let you in on some conventions we use.

First, there is the mode of address that we use throughout the book (except for this preface). Because Chris and Michael worked so closely and so hard on every word in this book, the use of “I” really means “both authors,” whereas the use of “we” means “the authors and you.” Although we sometimes use “you” directly, Michael and Chris lean toward the inclusive.

The wonderful thing about Windows Forms is how visual it is, and that’s why we use a lot of figures to illustrate its features. Some of those pictures really need to be in color to make the point, so be sure to check the color pages at the center of this book for those color plates.

As useful as figures are, we both think primarily in code. Code is shown in monospace type:

System.Console.WriteLine("Hello, Windows Forms.");

Console application activation is also shown in monospace type:

C:\> csc.exe hello.cs

When a part of a code snippet or a command line activation is of particular interest, we mark it in bold and often provide a comment:

// Notice the use of the .NET System namespace
System.Console.WriteLine("Hello, Windows Forms.");

When we want to direct your attention to a piece of code more fully, we replace superfluous code with ellipses:

class MyForm : System.Windows.Forms.Form {
... // fields
private void MyForm_Load(
object sender, System.ComponentModel.EventArgs e) {

MessageBox.Show("Hello from MyForm");

Furthermore, to make the printed code more readable, we often drop namespaces and protection keywords when they don’t provide additional information:

// Shortened "System.Windows.Forms.Form" base class
class MyForm : Form {
... // fields

// Removed "private" specifier and "System.ComponentModel" namespace
void MyForm_Load(object sender, EventArgs e) {
MessageBox.Show("Hello from MyForm");

When showing .NET attributes, we use their abbreviated name:

Serializable // Instead of SerializableAttribute
class MyCustomType {...}

C# lets you drop the “Attribute” suffix for convenience, but remember to append this suffix when you look up the details of the attribute class in the online documentation.

For clarity, we sometimes omit error checking from the printed code, but we try to leave it in the sample code that you’ll find at our web site.

In the text, we often put a word or phrase in italics to indicate a new term that we’re about to define. As an example of this kind of term and its definition, hegemony is a preponderant influence or authority, as well as a potent business practice.

Sometimes, we mention keyboard shortcuts because we find them convenient. The ones I mention are the default Visual Studio 2005 (VS05) key bindings for C# programmers. If you’re not using those key bindings, you’ll need to map the keyboard shortcuts to your own settings.

Finally, because this is the second edition of this book, we’ve taken care to mark new and updated types in the margins with graphics and in the code with comments. Also, for a summary of what’s new in Windows Forms, check out Appendix A: What’s New in Windows Forms 2.0.

Read More Show Less

Customer Reviews

Average Rating 4
( 1 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted July 9, 2006

    more powerful graphics than HTML

    Microsoft is well renowned for usually doggedly improving its products. This book by Sells and Weinhardt shows that trend in action, with its description of MS Windows Forms 2.0. It describes major improvements over version 1. The book is all about UI programming in a Microsoft operating system. The code examples are written in C# and the text shows a close interaction between Forms programming and the .NET framework. What is also interesting is the authors' remark that Forms 2 focuses on writing code for client applications, and not necessarily for web-based applications. After all, the very name .NET was chosen in the expectation that the latter would be what a lot of programmers would want. It is hard to tell what an arbitrary reader of this book might be looking for. But, as a guide, there is now a consistency possible in the look and feel with that of MS Office. The authors allude to a considerable demand in the marketplace for this. And given Microsoft's dominance with Office, this should be no surprise. Although one should add that you are not restricted to your applications having an Office-like look and feel. There is considerable leeway in customising, with code showing how this is done. Also, if some of you have written HTML pages, or web applications that use JavaScript or JScript, then Forms gives you a far richer set of widgets. It can make writing static HTML or HTML/JScript seem very restrictive. The layout of the book and its content should not present any problems if you have done some previous graphics programming (and not necessarily restricted to Microsoft environments). Most of the chapters deal with topics that are now common to any major graphics package. So there is a chapter on drawing basic entities like lines and curves, and filling areas. Another chapter on drawing text. Another on laying out widgets inside a Form (window). Obviously, the syntax is specific to Forms. But not the concepts, and if you already have those, everything else will be straightforward.

    0 out of 1 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)