package WindowsApplication2; import System.Collections.Generic.*; import System.Data.*; import System.Drawing.*; import System.ComponentModel.*; import System.Windows.Forms.*; /** * Form1 の概要の説明です。 */ public class Form1 extends System.Windows.Forms.Form { private Label label1; private TextBox textBox1; private TextBox textBox2; private Button button1; private Label label2; private Label label3; private Label label4; /** * 必要なデザイナ変数です。 */ private System.ComponentModel.IContainer components; public Form1() { // // Windows フォーム デザイナのサポートに必要です // InitializeComponent(); // // TODO: InitializeComponent 呼び出しの後でコンストラクタ コードを追加します // } #region Windows フォーム デザイナで生成されたコード /** * 使用中のリソースをすべてクリーンアップします。 */ protected void Dispose(boolean disposing) { if (disposing) { if (components != null) { components.Dispose(); } } super.Dispose(disposing); } /** * デザイナ サポートに必要なメソッドです。このメソッドの内容を * コード エディタで変更しないでください。 */ private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.set_AutoSize(true); this.label1.set_Location(new System.Drawing.Point(12, 109)); this.label1.set_Name("label1"); this.label1.set_Size(new System.Drawing.Size(0, 12)); this.label1.set_TabIndex(0); // // textBox1 // this.textBox1.set_Location(new System.Drawing.Point(14, 22)); this.textBox1.set_Name("textBox1"); this.textBox1.set_Size(new System.Drawing.Size(100, 19)); this.textBox1.set_TabIndex(1); // // textBox2 // this.textBox2.set_Location(new System.Drawing.Point(14, 60)); this.textBox2.set_Name("textBox2"); this.textBox2.set_Size(new System.Drawing.Size(100, 19)); this.textBox2.set_TabIndex(2); // // button1 // this.button1.set_Location(new System.Drawing.Point(14, 183)); this.button1.set_Name("button1"); this.button1.set_Size(new System.Drawing.Size(75, 23)); this.button1.set_TabIndex(3); this.button1.set_Text("足し算"); this.button1.set_UseVisualStyleBackColor(true); this.button1.add_Click(new System.EventHandler(this.button1_Click)); // // label2 // this.label2.set_AutoSize(true); this.label2.set_Location(new System.Drawing.Point(140, 29)); this.label2.set_Name("label2"); this.label2.set_Size(new System.Drawing.Size(78, 12)); this.label2.set_TabIndex(4); this.label2.set_Text("1.数字を入力"); // // label3 // this.label3.set_AutoSize(true); this.label3.set_Location(new System.Drawing.Point(140, 67)); this.label3.set_Name("label3"); this.label3.set_Size(new System.Drawing.Size(78, 12)); this.label3.set_TabIndex(5); this.label3.set_Text("2.数字を入力"); // // label4 // this.label4.set_AutoSize(true); this.label4.set_Location(new System.Drawing.Point(122, 194)); this.label4.set_Name("label4"); this.label4.set_Size(new System.Drawing.Size(120, 12)); this.label4.set_TabIndex(6); this.label4.set_Text("3.ボタンを押してください"); // // Form1 // this.set_AutoScaleDimensions(new System.Drawing.SizeF(6F, 12F)); this.set_AutoScaleMode(System.Windows.Forms.AutoScaleMode.Font); this.set_ClientSize(new System.Drawing.Size(284, 263)); this.get_Controls().Add(this.label4); this.get_Controls().Add(this.label3); this.get_Controls().Add(this.label2); this.get_Controls().Add(this.button1); this.get_Controls().Add(this.textBox2); this.get_Controls().Add(this.textBox1); this.get_Controls().Add(this.label1); this.set_Name("Form1"); this.set_Text("電卓基本動作"); this.ResumeLayout(false); this.PerformLayout(); } #endregion private void button1_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = Integer.parseInt(textBox2.get_Text()); int z = x + y; this.label1.set_Text("計算結果は "+z) ; } }