Start ⇒ All Programs ⇒ Visual Studio 2019If you want to open an existing project, pick the project with the
.sln
(solution) file extension as follows.
Otherwise, go to the next step.
WindowsFormsApp1
,C:\C#-workspace
, andCreate
:
Form1.cs
[Design].Label
, whose value of the property Text
is Name:
,
TextBox
, whose value of the property Name
is textBox1
, and
Button
s, whose values of the properties Name
are button1
and button2
, respectively, and the values of the properties Text
are Submit
and Exit
, respectively.
Form1.cs
.C:\C#-workspace\WindowsFormsApp1\Form1.cs
|
||||||||||||||||||||||||||||||||||||||||
|
InitializeComponent
loads the compiled page of a component.
Just leave it there.
This program is to send the entered name to the form, Form2
, which displays the name.
For how to write a C# program, check C# Tutorial.
Form2.cs
[Design].Project ⇒ Add Windows Form...
Form2.cs
[Design].Label
, whose values of the properties Name
and Text
are lable1
and an empty string, respectively.
Button
, whose values of the properties Name
and Text
are button1
and Home
, respectively.
Form2.cs
.C:\C#-workspace\WindowsFormsApp1\Form2.cs
|
||||||||||||||||||||||||||||||||||||
|
Note that thePage_Load( )
orForm2_Load( )
method may not work if it is entered manually. Instead, double click the form of the design view and use the template generated by it.
Build ⇒ Build Solution
Unable to copy file "obj\Release\WindowsFormsApp4.exe" to "bin\Release\WindowsFormsApp4.exe". The process cannot access the file 'bin\Release\WindowsFormsApp1.exe' because it is being used by another process.WindowsFormsApp1”most likely because the previous execution did not exit formally. To solve this problem, use the Windows Task Manager (
Ctrl
+Alt
+Delete
) to end the background processes.
Debug ⇒ Start Without DebuggingOne example of execution results is shown as follows:
![]() |
Submit ⇒ ⇐ Home |
![]() |