Creating
Windows Forms App (.NET Framework)
uses .NET Framework 4.7.2
Windows Forms App
uses .NET 6.0
Using Constructor
public partial class MyForm : System.Windows.Forms.Form
{
public MyForm()
{
InitializeComponent();
this.Text = "Form Title";
}
}
Using the Load Event
This is a windows form Built-in event
public partial class Form1 : System.Windows.Forms.Form
{
private void Form1_Load(object sender,
EventArgs e)
{
this.Text = "Form Title";
}
}
this Keyword
Passing In Arguments
It is possible to pass information to a windows form however you cannot use the Load Event for this.
The Load event does not allow arguments to be passed to it.
Constructor
This allows you to pass information into the form.
You can use a constructor which has the same name as the windows form.
protected string _passedIn;
public Form1(string sValue)
{
InitializeComponent()
this._passedIn = sValue;
}
If you are using the constructor you can probably move any code from the Load event into the constructor.
So that all your initialisation code is in one place.
Passing Out Results
Instead of actually passing values out of the windows form, one method is to use static class fields.
Static Fields
The simpliest way is to use a public static field inside an Internal Class.
This will allow the field to be accessed from anywhere, including inside Windows Forms.
internal class modSpecific
{
public static string _ProposalName;
}
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext