Escolar Documentos
Profissional Documentos
Cultura Documentos
WinForm Basics
. The class System.Windows.Forms.Form is
the base class of all WinForms in .Net
Write a new class to represent the WinForm
and derive it from the
System.Windows.Forms.Form class:
class MyForm : System.Windows.Form
{
...
}
class Test
{
static void Main()
{
}
Application.Run(new MyForm());
using System;
using System.Windows.Forms;
using System.Drawing;
namespace CSharpSchool
{
class Test
{
static void Main()
{
Application.Run(new MyWindow());
}
}
{
}
Application.Run(new MyWindow());
}
class MyWindow : Form
{
public MyWindow() : base()
{
// Form
this.Text = "My First Windows Application";
this.Size = new Size(300, 300);
this.StartPosition = FormStartPosition.CenterScreen;
Code Folding
One of the pleasant new features introduced in Visual
Studio.Net is code folding. With code folding, you
can fold/unfold the code using the + and - symbols
Usually the code can be folded/unfolded at each
scope boundary (method, class, namespace, property,
etc). You can also define regions within your code
and can fold/unfold the code within the region. The
region is defined using the #region...#endregion
preprocessor directives.
Form Designer
The form designer allows you to design the
graphical user interface just by placing the
controls on the form from the Toolbox
You can set a lot of properties of the form and
its controls using the Properties window
The Visual Studio.Net IDE automatically
writes the code in the source file as you place
the controls on the form and change their
properties.