English
Summary
Conclusions
Windows Forms is a technology for Windows desktop applications in which the interface consists of forms and controls—objects of classes derived from Control. A net10.0-windows project contains the Program.cs entry point with the Application.Run message loop and partial form classes: the programmer's code in MainForm.cs and the form designer's code in MainForm.Designer.cs. The application is event-driven: user actions are turned into events, and handlers with the sender and e parameters run on the UI thread. Layout panels, Anchor, and Dock make a form resilient to changes in size and scaling, Validating and ErrorProvider help validate input, and menus, standard dialogs, modal forms, DataGridView with BindingList<T>, and the timer make it possible to build full-featured data applications.
Self-check questions
- Which desktop application technologies exist in .NET? How does Windows Forms differ from WPF and .NET MAUI?
- Why does the target framework of a Windows Forms project look like
net10.0-windows? What is theUseWindowsFormsproperty for? - What does the
Application.Runmethod do? When do the lines after it execute? - Why is the form class split into the
MainForm.csandMainForm.Designer.csfiles? Why must you not editDesigner.csmanually? - Which Visual Studio windows are used when creating a form in the designer?
- Which properties do controls have in common? How does
Enabled = falsediffer fromVisible = false? - In what order are the
Load,Activated,Shown,FormClosing, andFormClosedevents raised? - How do you cancel closing a form?
- What is an event-driven application? What path does a mouse click take to reach a handler?
- What is passed in the
senderandeparameters of an event handler? - How do you connect one handler to several controls?
- How do the
AnchorandDockproperties differ? - What are
TableLayoutPanel,FlowLayoutPanel, andSplitContainerused for? - How do the
ValidatingandValidatedevents work? What is theCausesValidationproperty for? - How do you show an input error with
ErrorProvider? - How do you set shortcut keys for a menu item and a mnemonic for a button?
- How does a modal form differ from a modeless one? How do you pass data between forms?
- What are
BindingList<T>andBindingSourcefor when working withDataGridView? - Why is the Windows Forms timer unsuitable for precise time measurement?
Useful links
- Windows Forms documentation: https://learn.microsoft.com/dotnet/desktop/winforms/
- Windows Forms overview: https://learn.microsoft.com/dotnet/desktop/winforms/overview/
- Creating an app in Visual Studio: https://learn.microsoft.com/dotnet/desktop/winforms/get-started/create-app-visual-studio
- Controls: https://learn.microsoft.com/dotnet/desktop/winforms/controls/
- Events: https://learn.microsoft.com/dotnet/desktop/winforms/forms/events
- Order of events: https://learn.microsoft.com/dotnet/desktop/winforms/order-of-events-in-windows-forms
- Layout: https://learn.microsoft.com/dotnet/desktop/winforms/controls/layout
- Input validation: https://learn.microsoft.com/dotnet/desktop/winforms/input-keyboard/validation
- The
Formclass: https://learn.microsoft.com/dotnet/api/system.windows.forms.form - What's new in Windows Forms for .NET 10: https://learn.microsoft.com/dotnet/desktop/winforms/whats-new/net100