C#起步:WinForm当中的字符简例:
1 [assembly: System.Reflection.AssemblyVersion("1.2")]
2namespace MyNamespace
3 {
4using System;
5using System.Windows.Forms;
6
7
8public class MyForm :Form
9    {
10private Button btnLoad;
11private PictureBox pboxPhoto;
12public MyForm()
13        {
14this.Text="Hello Form 1.2";
15
16//Create and Configure the Button
17            btnLoad=new Button();
18 btnLoad.Text="&Load";
19            Console.WriteLine(btnLoad.Text);
20            btnLoad.Left=10;
21            btnLoad.Top=10;
22
23//Create and configure the PictureBox
24            pboxPhoto=new PictureBox();
25            pboxPhoto.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
26            pboxPhoto.Width=this.Width/2;
27            pboxPhoto.Height=this.Height/2;
28            pboxPhoto.Left=(this.Width-pboxPhoto.Width)/2;
29            Console.WriteLine(this.Width.ToString());
30            pboxPhoto.Top=(this.Height-pboxPhoto.Height)/2;
31            Console.WriteLine(this.Height.ToString());
32
33//Add our new controls to the Form
34this.Controls.Add(btnLoad);
35this.Controls.Add(pboxPhoto);
36        }
37public static void Main()
38        {
39            Application.Run(new MyForm());
40        }
41    }
42
borderbox43 }
&字符在winForm当中表⽰⽤来为使⽤的按钮指明⼀个热键
例如上⾯的案例,Alt+L就表明按下了Button

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。