Windows Forms getting started update for .NET 6 (#1215)

* Migrate code to .NET 6

* Add snippet ref in code

* Add net6 pics; move others to version folder

* Update winforms getting started

* Other .NET 5 references updated

* Lessen the amount of 'winforms'

* minor

* Update dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md

Co-authored-by: Tom Dykstra <[email protected]>

* Update dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md

Co-authored-by: Tom Dykstra <[email protected]>

* Update dotnet-desktop-guide/net/winforms/overview/index.md

Co-authored-by: Tom Dykstra <[email protected]>

* Update dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md

Co-authored-by: Tom Dykstra <[email protected]>

* Update dotnet-desktop-guide/net/winforms/overview/index.md

Co-authored-by: Tom Dykstra <[email protected]>

* Update dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md

Co-authored-by: Tom Dykstra <[email protected]>

* Update create-app-visual-studio.md

* Update create-app-visual-studio.md

* Update create-app-visual-studio.md

Co-authored-by: Tom Dykstra <[email protected]>
This commit is contained in:
Andy (Steve) De George
2021-11-16 14:09:35 -08:00
committed by GitHub
co-authored by Tom Dykstra
parent e17bdfae17
commit 4e4a3f5498
38 changed files with 292 additions and 185 deletions
@@ -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>