사용Tool : Microsoft Visual Studio 2003사용언어 : C#Form Design 을 다음과 같인 한 후 출력하기 Button 을 DbClick 하면 소스창이 나타난다.전체 Form 소스를 보면 다음과 같다.// 프롤로그using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;
namespace lovelydai_ex1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox nameBox;
private System.Windows.Forms.TextBox idBox;
private System.Windows.Forms.Button submitBtn;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.nameBox = new System.Windows.Forms.TextBox();
this.idBox = new System.Windows.Forms.TextBox();
this.submitBtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 32);
this.label1.TabIndex = 0;
this.label1.Text = "이름";
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 72);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 32);
this.label2.TabIndex = 1;
this.label2.Text = "학번";
//
// nameBox
//
this.nameBox.Location = new System.Drawing.Point(64, 24);
this.nameBox.Name = "nameBox";
this.nameBox.Size = new System.Drawing.Size(136, 21);
this.nameBox.TabIndex = 2;
this.nameBox.Text = "";
this.nameBox.TextChanged+=new System.EventHandler(this.nameBox_TextChanged);
//
// idBox
//
this.idBox.Location = new System.Drawing.Point(64, 72);
this.idBox.Name = "idBox";
this.idBox.Size = new System.Drawing.Size(136, 21);
this.idBox.TabIndex = 3;
this.idBox.Text = "";
//
// submitBtn
//
this.submitBtn.BackColor = System.Drawing.SystemColors.Desktop;
this.submitBtn.Font = new System.Drawing.Font("DotumChe", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(129)));
this.submitBtn.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.submitBtn.Location = new System.Drawing.Point(48, 144);
this.submitBtn.Name = "submitBtn";
this.submitBtn.Size = new System.Drawing.Size(192, 48);
this.submitBtn.TabIndex = 4;
this.submitBtn.Text = "출력하기";
this.submitBtn.Click += new System.EventHandler(this.submitBtn_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.submitBtn);
this.Controls.Add(this.idBox);
this.Controls.Add(this.nameBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void submitBtn_Click(object sender, System.EventArgs e)
{
MessageBox.Show("이름 : "+nameBox.Text+"\n"+"학번 : "+idBox.Text,"출력결과");
}
// 실제 출력을 담당하는 method..허벌나게 쉽다 쉬워 ㅋㅋ
// lable의 Text 속성 접근은 [개체명].Text
// 문자열은 다른 언어와 마찬가지로 "//..." 로 감싸준다
}
}
댓글
댓글 쓰기