mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 23:43:07 +02:00
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:
co-authored by
Tom Dykstra
parent
e17bdfae17
commit
4e4a3f5498
+29
@@ -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
|
||||
+30
-30
@@ -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
|
||||
+3
-13
@@ -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
|
||||
+37
@@ -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
|
||||
+10
@@ -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>
|
||||
+32
@@ -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>
|
||||
-15
@@ -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
|
||||
-14
@@ -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>
|
||||
Reference in New Issue
Block a user