📄 ex-13-01
字号:
// Example 13-01: Creating a hand-drawn Windows Form
using System;
using System.Windows.Forms;
namespace ProgCSharp
{
public class HandDrawnClass : Form
{
// a label to display Hello World
private System.Windows.Forms.Label
lblOutput;
// a cancel button
private System.Windows.Forms.Button
btnCancel;
public HandDrawnClass()
{
// create the objects
this.lblOutput =
new System.Windows.Forms.Label ();
this.btnCancel =
new System.Windows.Forms.Button ();
// set the form's title
this.Text = "Hello World";
// set up the output label
lblOutput.Location =
new System.Drawing.Point (16, 24);
lblOutput.Text = "Hello World!";
lblOutput.Size =
new System.Drawing.Size (216, 24);
// set up the cancel button
btnCancel.Location =
new System.Drawing.Point (150,200);
btnCancel.Size =
new System.Drawing.Size (112, 32);
btnCancel.Text = "&Cancel";
// set up the event handler
btnCancel.Click +=
new System.EventHandler (this.btnCancel_Click);
// Add the controls and set the client area
this.AutoScaleBaseSize =
new System.Drawing.Size (5, 13);
this.ClientSize =
new System.Drawing.Size (300, 300);
this.Controls.Add (this.btnCancel);
this.Controls.Add (this.lblOutput);
}
// handle the cancel event
protected void btnCancel_Click (
object sender, System.EventArgs e)
{
Application.Exit();
}
// Run the app
public static void Main()
{
Application.Run(new HandDrawnClass());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -