1. 程式人生 > 其它 >c#簡單的個人簡介自動生成程式

c#簡單的個人簡介自動生成程式

今天完成了一個.net的實驗,老師讓我們用TextBox、GroupBox、RadioButton、CheckBox、ComboBox、ListBox 控制元件這些控制元件編寫一個Windows應用程式,所以我寫了一個簡單的個人簡介生成軟體。

程式實現效果

程式碼

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy3._2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void label1_Click(object sender, EventArgs e)
{

}

private void label2_Click(object sender, EventArgs e)
{

}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{

}

private void label4_Click(object sender, EventArgs e)
{

}

private void groupBox1_Enter(object sender, EventArgs e)
{

}

private void label6_Click(object sender, EventArgs e)
{

}

private void label8_Click(object sender, EventArgs e)
{

}

private void label13_Click(object sender, EventArgs e)
{

}

private void button1_Click_1(object sender, EventArgs e)
{
if (textBox1.Text != "") { label7.Text = textBox1.Text; } //姓名
else MessageBox.Show("姓名不能為空!\n");
if (radioButton2.Checked) { label9.Text = radioButton2.Text; } //男
if (radioButton1.Checked) { label9.Text = radioButton1.Text; } //女
if (checkBox1.CheckState == CheckState.Checked) { label11.Text = checkBox1.Text; }//看書
else label10.Text = "";
if (checkBox2.CheckState == CheckState.Checked) { label16.Text = checkBox2.Text; }//籃球
else label11.Text = "";
if (checkBox3.CheckState == CheckState.Checked) { label17.Text = checkBox3.Text; }//打遊戲
else label12.Text = "";
if (checkBox1.CheckState == CheckState.Unchecked && checkBox2.CheckState == CheckState.Unchecked && checkBox3.CheckState == CheckState.Unchecked)
{ MessageBox.Show("選個愛好吧!\n"); }
if (comboBox1.Text != "") { label13.Text = comboBox1.Text; }//班級
else MessageBox.Show("班級不能為空!\n");
if (listBox1.Text != "") { label15.Text = listBox1.Text; } //座右銘
else MessageBox.Show("選個座右銘吧!\n");
}

private void button2_Click_1(object sender, EventArgs e)
{
this.Close();
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void label7_Click(object sender, EventArgs e)
{

}

private void label13_Click_1(object sender, EventArgs e)
{

}
}
}