This five-day course provides a practical, hands-on introduction to GUI development using Windows Forms and C#. The course introduces database programming in Windows, including use of Language Integrated Query (LINQ). The course covers powerful newer Windows Forms features, such as controls, data binding, and ClickOnce deployment for creating smart client applications. It covers interoperability with the next-generation Windows client framework, Windows Presentation Foundation (WPF). The course begins with a fundamental discussion of Windows Forms architecture and programming simple Windows Forms applications “from scratch.” Then the use of Visual Studio 2010 and the Forms Designer is introduced, which is used throughout the remainder of the course. Simple controls are covered, such as buttons, labels, textboxes, checkboxes, radio buttons and group boxes. List controls are surveyed, including list box, combo box, list view, and DomainUpDown. Dialogs are discussed in detail, including modal and modeless dialogs and associated controls. Menus, toolbars and status bars are covered. Advanced topics are introduced, including parent/child and owner/owned relationships, programming the Clipboard, visual inheritance, the BackgroundWorker component, and ClickOnce deployment. Advanced controls are introduced, including the tree view, tab control and SplitContainer. Resources are discussed, including their use in localization.
Objectives
Understand the fundamentals of Windows Forms architecture
Acquire proficiency in the use of Visual Studio to create professional class Windows
Gain a thorough grounding in the important controls provided by Windows Forms
Learn how to implement dialogs, menus, toolbars and status bars
Learn how to use advanced controls such as tree views, splitters and tabbed dialogs
Learn how to implement data access using ADO.NET and binding of controls
Use Language Integrated Query (LINQ) to access data from Windows Forms
Learn how to interoperate between Windows Forms and WPF
Detailed Outline
- Introduction to Windows Forms
- What Are Windows Forms?
- Windows Forms Class Hierarchy
- Control Class
- Form Class
- Form Class Methods
- Building a Form
- Application Class
- Simple Windows Application
- Using the .NET Framework SDK
- Using Controls
- Common Control Properties
- Ambient Control Properties
- Common Control Events
- Trapping Events
- Using the Button Control
- HelloWorld – Step 3
- Using the Label Control
- Chapter Section
- Chapter Section
- MSDN Documentation
- Visual Studio and the Forms Designer
- Examining the Forms Designer Generated Code
- Designing “Pretty” Forms
- Designing “Easy-to-Use” Forms
- Setting the Tab Order
- Defining Keyboard Shortcuts
- Defining Default and Cancel Buttons
- Using Controls
- Controls
- Using the TextBox – Again
- Using the Clipboard
- Using the RadioButton with a GroupBox
- Working with Ranges
- Using the NumericUpDown
- Using the ProgressBar
- Working with Dates
- Using the MonthCalendar
- Using DateTimePicker
- Other Controls
- Tracing
- Debug and Trace Classes
- Viewing Trace Output
- Debug Statements
- Debug Output
- WriteLine Syntax
- List Controls
- Working with Lists
- Using a ListBox
- Selected Items
- Selected Indices
- Other ListBox Features
- Adding and Removing Items Dynamically
- Using the ComboBox
- Storing Objects in List Controls
- Using the DomainUpDown Control
- Using a ListView
- Adding Columns to a ListView
- Adding items to a ListView
- Working with Dialogs
- Modal vs. Modeless Dialogs
- Message Box
- MessageBox Show Method
- Closing a Form
- Custom Dialogs
- Modal Dialogs
- Creating a New Form
- Common Dialog Properties
- Designing the Form
- Configuring the DialogResult
- Displaying the Form
- Accessing Data on the Form
- Changing the Behavior of a Button’s DialogResult
- Displaying Errors with the ErrorProvider Control
- Validation Using the ErrorProvider
- Modeless Dialogs
- Designing the Modeless Dialog
- Displaying the Form
- Managing the Relationship between the Parent and Modeless Dialog
- Programming the Apply and Close Buttons
- Programming the Apply Button
- Managing the Number of Instances of the Modeless Dialog
- Common Dialogs
- Using the Common Dialog Controls
- Menus, Toolbars and Status Bars
- Menus
- MainStrip Control
- Attaching a Menu to a Form
- Configuring Items in a Menu
- Responding to Menu Events
- DropDownOpening Event
- ContextMenuStrip Control
- Context Menu Events
- Handling Multiple Events
- Status Bars
- A Quick Status Bar
- Toolbars
- Importing Images
- Associating an Event Handler
- Image and Text on Buttons
- Advanced Windows Forms Topics
- Forms and Controls
- Parent/Child Relationships
- Owner/Owned Relationships
- Top-Most Forms
- Clipboard Object
- Placing Data on the Clipboard
- Retrieving Data from the Clipboard
- Visual Inheritance
- Building the Base Form
- BackgroundWorker Component
- BackgroundWorker Code
- ClickOnce Deployment
- Web Examples Setup
- Publishing a ClickOnce App
- Uninstalling the Application
- Installing the Application
- Using Advanced Controls
- Panel Control
- TreeView Control
- TreeView Properties
- TreeView Events
- TreeNode Class
- Adding Nodes
- Removing Nodes
- Iterating Through Nodes
- ImageList
- Image Collection Editor
- Tab Control
- Controls on Tab Pages
- Selected Index
- Tab Control Event Handling
- SplitContainer
- WebBrowser Control
- Resources
- Resources
- Image Resources
- Loading the Bitmaps
- Embedded Resources
- Accessing Embedded Resources
- Creating String Resources
- Strings in the Program
- Accessing Resources from Code
- Cultures and Internationalization
- .NET Support for Cultures
- Changing the Current Culture
- Building Localizable Forms
- MainForm.resx File
- Code for Localization
- Visual Studio Localization Support
- Applications and Settings
- The Application Class
- Starting and Stopping Applications
- Application Events
- Logging to a File
- Closing a Window
- Processing Windows Messages
- Filtering Messages
- Configuration Files
- Reading Configuration Files
- Configuration File and Visual Studio
- Application Settings
- Application Settings Using Visual Studio
- Application Configuration File
- User Configuration File
- Manual Application Settings
- Default Values of Settings
- Accessing the Registry
- Data Access
- ADO.NET
- .NET Namespaces
- ADO.NET Architecture
- .NET Data Providers
- SmallPub Database
- DataSet Architecture
- Why DataSet?
- DataSet Components
- XML File Schema Definition
- XML File Data
- Reading and Writing XML
- Accessing a DataSet
- Adding a New Row
- Searching and Updating a Row
- Deleting a Row
- Data Adapters
- Language Integrated Query (LINQ)
- Bridging Objects and Data
- Using Server Explorer
- Object Relational Designer
- IntelliSense
- Basic LINQ Query Operators
- Obtaining a Data Source
- Filtering
- Ordering
- Aggregation
- Obtaining Lists and Arrays
- Deferred Execution
- Modifying a Data Source
- Performing Inserts via LINQ to SQL
- Performing Deletes via LINQ to SQL
- Performing Updates via LINQ to SQL
- Data Binding
- Data Binding Concept
- Simple Data Binding
- Binding to a List
- Binding to a DataGrid
- DataView
- Filtering and Sorting
- DataView and Data Binding
- Column Formatting
- Data Binding with BindingSource
- BindingSource Architecture
- Binding to a List
- Setting up the Bindings
- Category Class
- Code in the From
- DataGridView Control
- Performing a Query
- Windows Forms and WPF Interoperation
- Windows Presentation Foundation
- What is XAML?
- Default Namespace
- XAML Language Namespace
- Code-Behind File
- Interoperating with Windows Forms
- Add a Form to a WPF Application
- Add a WPF Window to a Windows Forms Application
- Mixing WPF and Windows Forms in the Same Window
- Hosting a Windows Forms Control Using Code
- WindowsFormsHost via Code
- Windows Forms MonthCalendar
- WindowsFormsHost via XAML