## サンプル プログラム 6

1: using System;

2: using System.Drawing;

3: using System.Windows.Forms;

4:

5: class Hello: Form

6:{

7: static void btn1OnClick(object sender,EventArgs e)

8: {

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

10: }

11:

12: static void btn2OnClick(object sender,EventArgs e)

13: {

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

15: }

16:

17: public static void Main()

18: {

19: Hello hw = new Hello();

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

21:

22: TextBox box = new TextBox();

23: box.Parent = hw;

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

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

26:

27: Button btn1 = new Button();

28: btn1.Parent = hw;

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

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

31: btn1.Click +=new EventHandler(btn1OnClick);

32:

33: Button btn2 = new Button();

34: btn2.Parent = hw;

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

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

37: btn2.Click += new EventHandler(btn2OnClick);

38:

39: Application.Run(hw);

40: }

41:}