The Hello Windows Forms Application

Listing 3.1.1 is a simple Windows Forms application that displays the text “Hello Windows Forms!” in a label on the main form.

Listing 3.1.1. HWF.cs: The Hello Windows Forms Application
// HWF.cs
namespace HelloWindowsFormsNamespace {

    using System;
    using System.Drawing;
    using System.ComponentModel;
    using System.WinForms;
public class HelloWindowsForms : System.WinForms.Form
{
    //Label 1 displays the text message "Hello Windows Forms!"
    private System.WinForms.Label label1;

    //The constructor is where all initialization happens.
    //Forms created with the designer have an InitializeComponent() method.
    public HelloWindowsForms()
    { this.label1 = new System.WinForms.Label(); label1.Location = new System.Drawing.Point(8, ...

Get C# and the .NET Framework: The C++ Perspective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.