今天是要要继续完成C#的窗体应用程序
要求:
自己设计并编写一个 Windows 应用程序,要求用到 TextBox、GroupBox、
RadioButton、CheckBox、ComboBox、ListBox 控件。
界面布局:
partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (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.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.checkBox3 = new System.Windows.Forms.CheckBox(); this.label2 = new System.Windows.Forms.Label(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); this.listBox1 = new System.Windows.Forms.ListBox(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label(); this.label14 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(595, 75); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(150, 30); this.textBox1.TabIndex = 0; this.textBox1.Text = "请输入姓名"; this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(526, 78); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(64, 24); this.label1.TabIndex = 1; this.label1.Text = "姓名:"; // // groupBox1 // this.groupBox1.Controls.Add(this.radioButton2); this.groupBox1.Controls.Add(this.radioButton1); this.groupBox1.Location = new System.Drawing.Point(526, 135); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(273, 91); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "请选择性别"; // // radioButton1 // this.radioButton1.AutoSize = true; this.radioButton1.Location = new System.Drawing.Point(6, 48); this.radioButton1.Name = "radioButton1"; this.radioButton1.Size = new System.Drawing.Size(53, 28); this.radioButton1.TabIndex = 0; this.radioButton1.TabStop = true; this.radioButton1.Text = "男"; this.radioButton1.UseVisualStyleBackColor = true; // // radioButton2 // this.radioButton2.AutoSize = true; this.radioButton2.Location = new System.Drawing.Point(94, 48); this.radioButton2.Name = "radioButton2"; this.radioButton2.Size = new System.Drawing.Size(53, 28); this.radioButton2.TabIndex = 1; this.radioButton2.TabStop = true; this.radioButton2.Text = "女"; this.radioButton2.UseVisualStyleBackColor = true; // // checkBox1 // this.checkBox1.AutoSize = true; this.checkBox1.Location = new System.Drawing.Point(626, 248); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(90, 28); this.checkBox1.TabIndex = 3; this.checkBox1.Text = "打篮球"; this.checkBox1.UseVisualStyleBackColor = true; // // checkBox2 // this.checkBox2.AutoSize = true; this.checkBox2.Location = new System.Drawing.Point(722, 248); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(108, 28); this.checkBox2.TabIndex = 4; this.checkBox2.Text = "打乒乓球"; this.checkBox2.UseVisualStyleBackColor = true; // // checkBox3 // this.checkBox3.AutoSize = true; this.checkBox3.Location = new System.Drawing.Point(836, 248); this.checkBox3.Name = "checkBox3"; this.checkBox3.Size = new System.Drawing.Size(90, 28); this.checkBox3.TabIndex = 5; this.checkBox3.Text = "踢足球"; this.checkBox3.UseVisualStyleBackColor = true; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(526, 248); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(100, 24); this.label2.TabIndex = 6; this.label2.Text = "兴趣爱好:"; // // comboBox1 // this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox1.FormattingEnabled = true; this.comboBox1.Items.AddRange(new object[] { "软件工程", "计算机科学与技术", "网络安全"}); this.comboBox1.Location = new System.Drawing.Point(601, 303); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(182, 32); this.comboBox1.TabIndex = 7; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(531, 311); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(64, 24); this.label3.TabIndex = 8; this.label3.Text = "专业:"; // // listBox1 // this.listBox1.FormattingEnabled = true; this.listBox1.ItemHeight = 24; this.listBox1.Items.AddRange(new object[] { "越努力,越幸运。", "是吧是成功之母"}); this.listBox1.Location = new System.Drawing.Point(620, 370); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(180, 124); this.listBox1.TabIndex = 9; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(532, 375); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(82, 24); this.label4.TabIndex = 10; this.label4.Text = "座右铭:"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(82, 81); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(64, 24); this.label5.TabIndex = 11; this.label5.Text = "姓名:"; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(152, 81); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(63, 24); this.label6.TabIndex = 12; this.label6.Text = "label6"; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(82, 135); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(64, 24); this.label7.TabIndex = 13; this.label7.Text = "性别:"; // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(152, 135); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(63, 24); this.label8.TabIndex = 14; this.label8.Text = "label8"; // // label9 // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(82, 187); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(100, 24); this.label9.TabIndex = 15; this.label9.Text = "兴趣爱好:"; // // label10 // this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(176, 187); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(74, 24); this.label10.TabIndex = 16; this.label10.Text = "label10"; // // label11 // this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(82, 248); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(64, 24); this.label11.TabIndex = 17; this.label11.Text = "专业:"; // // label12 // this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(152, 252); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(74, 24); this.label12.TabIndex = 18; this.label12.Text = "label12"; // // label13 // this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(82, 303); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(82, 24); this.label13.TabIndex = 19; this.label13.Text = "座右铭:"; // // label14 // this.label14.AutoSize = true; this.label14.Location = new System.Drawing.Point(152, 303); this.label14.Name = "label14"; this.label14.Size = new System.Drawing.Size(74, 24); this.label14.TabIndex = 20; this.label14.Text = "label14"; // // button1 // this.button1.Location = new System.Drawing.Point(577, 546); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(112, 34); this.button1.TabIndex = 21; this.button1.Text = "提交"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1081, 656); this.Controls.Add(this.button1); this.Controls.Add(this.label14); this.Controls.Add(this.label13); this.Controls.Add(this.label12); this.Controls.Add(this.label11); this.Controls.Add(this.label10); this.Controls.Add(this.label9); this.Controls.Add(this.label8); this.Controls.Add(this.label7); this.Controls.Add(this.label6); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.listBox1); this.Controls.Add(this.label3); this.Controls.Add(this.comboBox1); this.Controls.Add(this.label2); this.Controls.Add(this.checkBox3); this.Controls.Add(this.checkBox2); this.Controls.Add(this.checkBox1); this.Controls.Add(this.groupBox1); this.Controls.Add(this.label1); this.Controls.Add(this.textBox1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private TextBox textBox1; private Label label1; private GroupBox groupBox1; private RadioButton radioButton2; private RadioButton radioButton1; private CheckBox checkBox1; private CheckBox checkBox2; private CheckBox checkBox3; private Label label2; private ComboBox comboBox1; private Label label3; private ListBox listBox1; private Label label4; private Label label5; private Label label6; private Label label7; private Label label8; private Label label9; private Label label10; private Label label11; private Label label12; private Label label13; private Label label14; private Button button1; }
程序功能:
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { label6.Text= textBox1.Text; if (radioButton1.Checked) { label8.Text = "男"; } if (radioButton2.Checked) { label8.Text = "男"; } if(checkBox1.CheckState== CheckState.Checked) { label10.Text = ""; label10.Text += checkBox1.Text; } if (checkBox2.CheckState == CheckState.Checked) { label10.Text = ""; label10.Text += checkBox2.Text; } if (checkBox3.CheckState == CheckState.Checked) { label10.Text = ""; label10.Text += checkBox3.Text; } label12.Text = comboBox1.Text; label14.Text = listBox1.Text; } }
标签:C#,Text,System,学习,new,true,Drawing,Size From: https://www.cnblogs.com/1774323810com/p/16999302.html