サンプル  プログラム6

1: usingSystem;

2: usingSystem.Drawing;

3: usingSystem.Windows.Forms;

4:

5: classHello:Form

6: {

7:   staticvoidbtn1OnClick(object sender, EventArgs e)

8:   {

9:     MessageBox.Show("正解せいかい!");

10:   }

11:

12:   staticvoidbtn2OnClick(object sender, EventArgs e)

13:   {

14:     MessageBox.Show("残念ざんねん!");

15:   }

16:

17:   publicstaticvoidMain()

18:   {

19:     Hellohw=newHello();

20:     hw.Text="アプリケーションめい";

21:

22:     TextBoxbox=newTextBox();

23:     box.Parent=hw;

24:     box.Width=box.Width*2;

25:     box.Text="茨城いばらき  県庁けんちょう  所在地しょざいち";

26:

27:     Buttonbtn1=newButton();

28:     btn1.Parent=hw;

29:     btn1.Location=newPoint(0, box.Height);

30:     btn1.Text="水戸市みとし";

31:     btn1.Click+= newEventHandler(btn1OnClick);

32:

33:     Buttonbtn2=newButton();

34:     btn2.Parent=hw;

35:     btn2.Location=newPoint(0, box.Height + btn1.Height);

36:     btn2.Text="つくば";

37:     btn2.Click+=newEventHandler(btn2OnClick);

38:

39:     Application.Run(hw);

40:   }

41: }