Merge pull request #1218 from dotnet/main

Publish
This commit is contained in:
Andy (Steve) De George
2021-11-16 14:22:53 -08:00
committed by GitHub
38 changed files with 292 additions and 185 deletions
+4 -4
View File
@@ -10,20 +10,20 @@ metadata:
ms.product: dotnet
author: adegeo
ms.author: adegeo
ms.date: 10/21/2020
ms.date: 11/15/2021
# linkListType: architecture | concept | deploy | download | get-started | how-to-guide | learn | overview | quickstart | reference | sample | tutorial | video | whats-new
landingContent:
- title: .NET 5 (and .NET Core 3.1)
- title: .NET 5+ (and .NET Core 3.1)
linkLists:
- linkListType: overview
links:
- text: Windows Presentation Foundation (WPF)
url: net/wpf/index.yml?view=netdesktop-5.0&preserve-view=true
url: net/wpf/index.yml?view=netdesktop-6.0&preserve-view=true
- text: Windows Forms (WinForms)
url: net/winforms/index.yml?view=netdesktop-5.0&preserve-view=true
url: net/winforms/index.yml?view=netdesktop-6.0&preserve-view=true
- title: .NET Framework
linkLists:
@@ -1,16 +1,16 @@
---
title: "Create a new app with Visual Studio tutorial"
description: Follow this tutorial to learn how to create a new Windows Forms app for .NET with Visual Studio 2019.
ms.date: 10/26/2020
ms.date: 11/15/2021
ms.topic: tutorial
dev_langs:
- "csharp"
- "vb"
---
# Tutorial: Create a new WinForms app (Windows Forms .NET)
# Tutorial: Create a Windows Forms app with .NET
In this short tutorial, you'll learn how to create a new Windows Forms (WinForms) app with Visual Studio. Once the initial app has been generated, you'll learn how to add controls and how to handle events. By the end of this tutorial, you'll have a simple app that adds names to a list box.
In this short tutorial, you'll learn how to create a new Windows Forms app with Visual Studio. Once the initial app has been generated, you'll learn how to add controls and how to handle events. By the end of this tutorial, you'll have a simple app that adds names to a list box.
[!INCLUDE [desktop guide under construction](../../includes/desktop-guide-preview-note.md)]
@@ -18,25 +18,39 @@ In this tutorial, you learn how to:
> [!div class="checklist"]
>
> - Create a new WinForms app
> - Create a new Windows Forms app
> - Add controls to a form
> - Handle control events to provide app functionality
> - Run the app
## Prerequisites
:::moniker range="netdesktop-5.0"
- [Visual Studio 2019 version 16.8 or later versions](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2019+desktopguide+winforms)
- Select the [Visual Studio Desktop workload](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-workloads)
- Select the [.NET 5 individual component](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-individual-components)
## Create a WinForms app
:::moniker-end
:::moniker range="netdesktop-6.0"
- [Visual Studio 2022 version 17.0 or later versions](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&0utm_content=download+vs2022+desktopguide+winforms)
- Select the [.NET desktop development workload](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-workloads)
- Select the [.NET 6 individual component](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-individual-components)
:::moniker-end
## Create a Windows Forms app
The first step to creating a new app is opening Visual Studio and generating the app from a template.
:::moniker range="netdesktop-5.0"
01. Open Visual Studio.
01. Select **Create a new project**.
:::image type="content" source="media/create-app-visual-studio/vs-create-new-project.png" alt-text="Create a new Windows Forms project in Visual Studio 2019 for .NET":::
:::image type="content" source="media/create-app-visual-studio/netdesktop-5.0/vs-create-new-project.png" alt-text="Create a new Windows Forms project in Visual Studio 2019 for .NET":::
01. In the **Search for templates** box, type **winforms**, and then press <kbd>Enter</kbd>.
01. In the **code language** dropdown, choose **C#** or **Visual Basic**.
@@ -45,25 +59,67 @@ The first step to creating a new app is opening Visual Studio and generating the
> [!IMPORTANT]
> Don't select the **Windows Forms App (.NET _Framework_)** template.
:::image type="content" source="media/create-app-visual-studio/vs-template-search.png" alt-text="Search for the Windows Forms template in Visual Studio 2019 for .NET":::
:::image type="content" source="media/create-app-visual-studio/netdesktop-5.0/vs-template-search.png" alt-text="Search for the Windows Forms template in Visual Studio 2019 for .NET":::
01. In the **Configure your new project** window, set the **Project name** to **Names** and click **Create**.
You can also save your project to a different folder by adjusting the **Location** setting.
:::image type="content" source="media/create-app-visual-studio/vs-config-new-project.png" alt-text="Configure new Windows Forms project in Visual Studio 2019 for .NET":::
:::image type="content" source="media/create-app-visual-studio/netdesktop-5.0/vs-config-new-project.png" alt-text="Configure new Windows Forms project in Visual Studio 2019 for .NET":::
:::moniker-end
:::moniker range="netdesktop-6.0"
01. Open Visual Studio.
01. Select **Create a new project**.
:::image type="content" source="media/create-app-visual-studio/netdesktop-6.0/vs-create-new-project.png" alt-text="Create a new Windows Forms project in Visual Studio 2022 for .NET.":::
01. In the **Search for templates** box, type **winforms**, and wait for the search results to appear.
01. In the **code language** dropdown, choose **C#** or **Visual Basic**.
01. In the list of templates, select **Windows Forms App** and then click **Next**.
> [!IMPORTANT]
> Don't select the **Windows Forms App (.NET _Framework_)** template.
The following image shows both C# and Visual Basic .NET project templates. If you applied the **code language** filter, you'll see the corresponding template.
:::image type="content" source="media/create-app-visual-studio/netdesktop-6.0/vs-template-search.png" alt-text="Search for the Windows Forms template in Visual Studio 2022 for .NET":::
01. In the **Configure your new project** window, set the **Project name** to _Names_ and click **Next**.
You can also save your project to a different folder by adjusting the **Location** path.
:::image type="content" source="media/create-app-visual-studio/netdesktop-6.0/vs-config-new-project.png" alt-text="Configure new Windows Forms project in Visual Studio 2022 for .NET":::
01. Finally, in the **Additional information** window, select **.NET 6.0 (Long-term support)** for the **Framework** setting, and then click **Create**.
:::image type="content" source="media/create-app-visual-studio/netdesktop-6.0/vs-select-framework.png" alt-text="Select the target framework for a Windows Forms project in Visual Studio 2022":::
:::moniker-end
Once the app is generated, Visual Studio should open the designer pane for the default form, _Form1_. If the form designer isn't visible, double-click on the form in the **Solution Explorer** pane to open the designer window.
### Important parts of Visual Studio
Support for WinForms in Visual Studio has four important components that you'll interact with as you create an app:
Support for Windows Forms in Visual Studio has four important components that you'll interact with as you create an app:
:::image type="content" source="media/create-app-visual-studio/vs-main-window.png" alt-text="The important components of Visual Studio you should know when creating a Windows Forms project for .NET":::
:::moniker range="netdesktop-5.0"
:::image type="content" source="media/create-app-visual-studio/netdesktop-5.0/vs-main-window.png" alt-text="The important components of Visual Studio 2019 you should know when creating a Windows Forms project for .NET":::
:::moniker-end
:::moniker range="netdesktop-6.0"
:::image type="content" source="media/create-app-visual-studio/netdesktop-6.0/vs-main-window.png" alt-text="The important components of Visual Studio 2022 you should know when creating a Windows Forms project for .NET":::
:::moniker-end
01. Solution Explorer
All if your project files, code, forms, resources, will appear in this pane.
All of your project files, code, forms, resources, will appear in this pane.
02. Properties
@@ -111,7 +167,17 @@ You can position and size the controls according to the following settings. Eith
You should have a form in the designer that looks similar to the following:
:::image type="content" source="media/create-app-visual-studio/vs-form-preview.png" alt-text="Visual Studio 2019 designer with the form open for Windows Forms for .NET":::
:::moniker range="netdesktop-5.0"
:::image type="content" source="media/create-app-visual-studio/netdesktop-5.0/vs-form-preview.png" alt-text="Visual Studio 2019 designer with the form open for Windows Forms for .NET":::
:::moniker-end
:::moniker range="netdesktop-6.0"
:::image type="content" source="media/create-app-visual-studio/netdesktop-6.0/vs-form-preview.png" alt-text="Visual Studio 2022 designer with the form open for Windows Forms for .NET":::
:::moniker-end
## Handle events
@@ -140,27 +206,25 @@ Now that the form has all of its controls laid out, you need to handle the event
01. The following code demonstrates adding a name to the `lstNames` control:
```csharp
private void btnAdd_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtName.Text) && !lstNames.Items.Contains(txtName.Text))
lstNames.Items.Add(txtName.Text);
}
```
:::code language="csharp" source="snippets/create-app-visual-studio/csharp/Form1.cs" id="buttonClick":::
```vb
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
If Not String.IsNullOrWhiteSpace(txtName.Text) And Not lstNames.Items.Contains(txtName.Text) Then
lstNames.Items.Add(txtName.Text)
End If
End Sub
```
:::code language="vb" source="snippets/create-app-visual-studio/vb/Form1.vb" id="buttonClick":::
## Run the app
Now that the event has been coded, you can run the app by pressing the <kbd>F5</kbd> key or by selecting **Debug** > **Start Debugging** from the menu. The form displays and you can enter a name in the textbox and then add it by clicking the button.
:::image type="content" source="media/create-app-visual-studio/app-running.png" alt-text="Running a Windows Forms for .NET app.":::
:::moniker range="netdesktop-5.0"
:::image type="content" source="media/create-app-visual-studio/netdesktop-5.0/app-running.png" alt-text="Running a Windows Forms for .NET app in Visual Studio 2019.":::
:::moniker-end
:::moniker range="netdesktop-6.0"
:::image type="content" source="media/create-app-visual-studio/netdesktop-6.0/app-running.png" alt-text="Running a Windows Forms for .NET app in Visual Studio 2022.":::
:::moniker-end
## Next steps
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

@@ -1,4 +1,4 @@
namespace project
namespace Names
{
partial class Form1
{
@@ -30,8 +30,8 @@
{
this.label1 = new System.Windows.Forms.Label();
this.lstNames = new System.Windows.Forms.ListBox();
this.btnAdd = new System.Windows.Forms.Button();
this.txtName = new System.Windows.Forms.TextBox();
this.btnAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
@@ -52,36 +52,34 @@
this.lstNames.Size = new System.Drawing.Size(120, 94);
this.lstNames.TabIndex = 1;
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(138, 55);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(100, 23);
this.btnAdd.TabIndex = 2;
this.btnAdd.Text = "Add Name";
this.btnAdd.UseVisualStyleBackColor = true;
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(138, 26);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(100, 23);
this.txtName.TabIndex = 3;
this.txtName.TabIndex = 2;
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(138, 55);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(100, 23);
this.btnAdd.TabIndex = 3;
this.btnAdd.Text = "Add Name";
this.btnAdd.UseVisualStyleBackColor = true;
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(252, 141);
this.Controls.Add(this.txtName);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.txtName);
this.Controls.Add(this.lstNames);
this.Controls.Add(this.label1);
this.Cursor = System.Windows.Forms.Cursors.Default;
this.Name = "Form1";
this.Text = "Names";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
@@ -89,10 +87,9 @@
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox lstNames;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.TextBox txtName;
private Label label1;
private ListBox lstNames;
private TextBox txtName;
private Button btnAdd;
}
}
}
@@ -0,0 +1,18 @@
namespace Names
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// <buttonClick>
private void btnAdd_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtName.Text) && !lstNames.Items.Contains(txtName.Text))
lstNames.Items.Add(txtName.Text);
}
// </buttonClick>
}
}
@@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtName.Text) && !lstNames.Items.Contains(txtName.Text))
lstNames.Items.Add(txtName.Text);
}
}
}
@@ -2,12 +2,10 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Update="Main.cs" />
</ItemGroup>
</Project>
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace project
namespace Names
{
static class Program
internal static class Program
{
/// <summary>
/// The main entry point for the application.
@@ -14,10 +8,8 @@ namespace project
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}
}
@@ -0,0 +1,29 @@
Imports Microsoft.VisualBasic.ApplicationServices
Namespace My
' The following events are available for MyApplication:
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
' **NEW** ApplyApplicationDefaults: Raised when the application queries default values to be set for the application.
' Example:
' Private Sub MyApplication_ApplyApplicationDefaults(sender As Object, e As ApplyApplicationDefaultsEventArgs) Handles Me.ApplyApplicationDefaults
'
' ' Setting the application-wide default Font:
' e.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular)
'
' ' Setting the HighDpiMode for the Application:
' e.HighDpiMode = HighDpiMode.PerMonitorV2
'
' ' If a splash dialog is used, this sets the minimum display time:
' e.MinimumSplashScreenDisplayTime = 4000
' End Sub
Partial Friend Class MyApplication
End Class
End Namespace
@@ -22,20 +22,27 @@ Partial Class Form1
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.lstNames = New System.Windows.Forms.ListBox()
Me.txtName = New System.Windows.Forms.TextBox()
Me.btnAdd = New System.Windows.Forms.Button()
Me.txtName = New System.Windows.Forms.TextBox()
Me.lstNames = New System.Windows.Forms.ListBox()
Me.label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Label1
'btnAdd
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(12, 9)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(44, 15)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Names"
Me.btnAdd.Location = New System.Drawing.Point(138, 55)
Me.btnAdd.Name = "btnAdd"
Me.btnAdd.Size = New System.Drawing.Size(100, 23)
Me.btnAdd.TabIndex = 7
Me.btnAdd.Text = "Add Name"
Me.btnAdd.UseVisualStyleBackColor = True
'
'txtName
'
Me.txtName.Location = New System.Drawing.Point(138, 26)
Me.txtName.Name = "txtName"
Me.txtName.Size = New System.Drawing.Size(100, 23)
Me.txtName.TabIndex = 6
'
'lstNames
'
@@ -44,23 +51,16 @@ Partial Class Form1
Me.lstNames.Location = New System.Drawing.Point(12, 27)
Me.lstNames.Name = "lstNames"
Me.lstNames.Size = New System.Drawing.Size(120, 94)
Me.lstNames.TabIndex = 1
Me.lstNames.TabIndex = 5
'
'txtName
'label1
'
Me.txtName.Location = New System.Drawing.Point(138, 26)
Me.txtName.Name = "txtName"
Me.txtName.Size = New System.Drawing.Size(100, 23)
Me.txtName.TabIndex = 2
'
'btnAdd
'
Me.btnAdd.Location = New System.Drawing.Point(138, 55)
Me.btnAdd.Name = "btnAdd"
Me.btnAdd.Size = New System.Drawing.Size(100, 23)
Me.btnAdd.TabIndex = 3
Me.btnAdd.Text = "Add Name"
Me.btnAdd.UseVisualStyleBackColor = True
Me.label1.AutoSize = True
Me.label1.Location = New System.Drawing.Point(12, 9)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(44, 15)
Me.label1.TabIndex = 4
Me.label1.Text = "Names"
'
'Form1
'
@@ -70,7 +70,7 @@ Partial Class Form1
Me.Controls.Add(Me.btnAdd)
Me.Controls.Add(Me.txtName)
Me.Controls.Add(Me.lstNames)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.label1)
Me.Name = "Form1"
Me.Text = "Names"
Me.ResumeLayout(False)
@@ -78,8 +78,8 @@ Partial Class Form1
End Sub
Friend WithEvents Label1 As Windows.Forms.Label
Friend WithEvents lstNames As Windows.Forms.ListBox
Friend WithEvents txtName As Windows.Forms.TextBox
Friend WithEvents btnAdd As Windows.Forms.Button
Private WithEvents btnAdd As Button
Private WithEvents txtName As TextBox
Private WithEvents lstNames As ListBox
Private WithEvents label1 As Label
End Class
@@ -1,19 +1,9 @@
Imports System.Windows.Forms
Imports System.Drawing
Partial Public Class Form1
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Public Class Form1
' <buttonClick>
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
If Not String.IsNullOrWhiteSpace(txtName.Text) And Not lstNames.Items.Contains(txtName.Text) Then
lstNames.Items.Add(txtName.Text)
End If
End Sub
' </buttonClick>
End Class
@@ -0,0 +1,37 @@
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' or if you encounter build errors in this file, go to the Project Designer
' (go to Project Properties or double-click the My Project node in
' Solution Explorer), and make changes on the Application tab.
'
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()>
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = False
Me.EnableVisualStyles = True
Me.SaveMySettingsOnExit = True
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()>
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Form1
End Sub
End Class
End Namespace
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain>
<MainForm>Form1</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<StartupObject>Sub Main</StartupObject>
<UseWindowsForms>true</UseWindowsForms>
<MyType>WindowsForms</MyType>
</PropertyGroup>
<ItemGroup>
<Import Include="System.Data" />
<Import Include="System.Drawing" />
<Import Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Update="My Project\Application.Designer.vb">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
</Project>
@@ -1,15 +0,0 @@
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows.Forms
Module Program
Sub Main(args As String())
Application.SetHighDpiMode(HighDpiMode.SystemAware)
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Module
@@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<StartupObject>Sub Main</StartupObject>
</PropertyGroup>
<ItemGroup>
<Compile Update="Main.vb" />
</ItemGroup>
</Project>
+1 -1
View File
@@ -7,7 +7,7 @@ metadata:
title: Windows Forms for .NET 6 documentation
description: Learn about using Windows Forms, an open-source, graphical user interface for Windows, on .NET 6.
ms.topic: landing-page
ms.date: 10/26/2020
ms.date: 11/15/2021
# linkListType: architecture | concept | deploy | download | get-started | how-to-guide | learn | overview | quickstart | reference | sample | tutorial | video | whats-new
@@ -1,7 +1,7 @@
---
title: What is Windows Forms
description: This article gives an overview of Windows Forms with .NET Core and .NET 5.
ms.date: 10/26/2020
ms.date: 11/15/2021
ms.topic: overview
#Customer intent: As a developer, I want to understand the components of Windows Forms so that I can understand the overall picture of Windows Forms.
---
@@ -16,13 +16,15 @@ There are two implementations of Windows Forms:
01. The open-source implementation hosted on [GitHub](https://github.com/dotnet/winforms).
This version runs on .NET 5 and .NET Core 3.1. The Windows Forms Visual Designer requires, at a minimum, [Visual Studio 2019 version 16.8 Preview](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2019+desktopguide+winforms).
This version runs on .NET 5+ (and .NET Core 3.1). The Windows Forms Visual Designer requires, at a minimum, [Visual Studio 2019 version 16.8](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2019+desktopguide+winforms).
01. The .NET Framework 4 implementation that's supported by Visual Studio 2019 and Visual Studio 2017.
The latest version of Windows Forms is for .NET 6 using [Visual Studio 2022 version 17.0](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2022+desktopguide+winforms).
01. The .NET Framework 4 implementation that's supported by Visual Studio 2022, Visual Studio 2019, and Visual Studio 2017.
.NET Framework 4 is a Windows-only version of .NET and is considered a Windows Operating System component. This version of Windows Forms is distributed with .NET Framework.
This Desktop Guide is written for Windows Forms on .NET 5. For more information about the .NET Framework version of Windows Forms, see [Windows Forms for .NET Framework](../../../framework/winforms/index.yml?view=netframeworkdesktop-4.8&preserve-view=true).
This Desktop Guide is written for Windows Forms on .NET 5 and later versions. For more information about the .NET Framework version of Windows Forms, see [Windows Forms for .NET Framework](../../../framework/winforms/index.yml?view=netframeworkdesktop-4.8&preserve-view=true).
## Introduction
@@ -30,11 +32,11 @@ Windows Forms is a UI framework for building Windows desktop apps. It provides o
With Windows Forms, you develop graphically rich apps that are easy to deploy, update, and work while offline or while connected to the internet. Windows Forms apps can access the local hardware and file system of the computer where the app is running.
To learn how to create a Windows Forms app, see [Tutorial: Create a new WinForms app (Windows Forms .NET)](../get-started/create-app-visual-studio.md).
To learn how to create a Windows Forms app, see [Tutorial: Create a new WinForms app](../get-started/create-app-visual-studio.md).
## Why migrate from .NET Framework
Windows Forms for .NET 5.0 provides new features and enhancements over .NET Framework. For more information, see [What's new in Windows Forms for .NET 5](../whats-new/index.md). To learn how to migrate an app, see [How to migrate a Windows Forms desktop app to .NET 5](../migration/index.md).
Windows Forms for .NET 6.0 provides new features and enhancements over .NET Framework. For more information, see [What's new in Windows Forms for .NET 6](../whats-new/net60.md) and [.NET 5](../whats-new/net50.md). To learn how to migrate an app, see [How to migrate a Windows Forms desktop app to .NET 5](../migration/index.md).
## Build rich, interactive user interfaces
@@ -127,6 +129,6 @@ For step-by-step information about how to use these features, see the following
## See also
- [Tutorial: Create a new WinForms app (Windows Forms .NET)](../get-started/create-app-visual-studio.md)
- [How to add a form to a project (Windows Forms .NET)](../forms/how-to-add.md)
- [Add a control (Windows Forms .NET)](../controls/how-to-add-to-a-form.md)
- [Tutorial: Create a new WinForms app](../get-started/create-app-visual-studio.md)
- [How to add a form to a project](../forms/how-to-add.md)
- [Add a control](../controls/how-to-add-to-a-form.md)