📄 stuimfo.cs
字号:
//
// checkBox2
//
this.checkBox2.Location = new System.Drawing.Point(224, 216);
this.checkBox2.Name = "checkBox2";
this.checkBox2.TabIndex = 15;
this.checkBox2.Text = "跳舞";
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
//
// checkBox3
//
this.checkBox3.Location = new System.Drawing.Point(280, 216);
this.checkBox3.Name = "checkBox3";
this.checkBox3.TabIndex = 16;
this.checkBox3.Text = "美术";
this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 328);
this.button1.Name = "button1";
this.button1.TabIndex = 17;
this.button1.Text = "添加";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(8, 328);
this.button2.Name = "button2";
this.button2.TabIndex = 18;
this.button2.Text = "保存";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.BackColor = System.Drawing.SystemColors.Info;
this.button3.Location = new System.Drawing.Point(224, 328);
this.button3.Name = "button3";
this.button3.TabIndex = 19;
this.button3.Text = "退出";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(104, 168);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.TabIndex = 20;
this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged);
//
// label7
//
this.label7.Location = new System.Drawing.Point(24, 176);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(72, 24);
this.label7.TabIndex = 21;
this.label7.Text = "出生年月:";
this.label7.Click += new System.EventHandler(this.label7_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(312, 280);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(48, 23);
this.button4.TabIndex = 22;
this.button4.Text = "确定";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// StuImfo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Info;
this.ClientSize = new System.Drawing.Size(368, 369);
this.Controls.Add(this.button4);
this.Controls.Add(this.label7);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkBox3);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "StuImfo";
this.Text = "新建学生信息";
this.Load += new System.EventHandler(this.StuImfo_Load);
this.ResumeLayout(false);
}
#endregion
private void label1_Click(object sender, System.EventArgs e)
{
}
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton1.Checked)
textBox3.Text =radioButton1.Text ;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void button2_Click(object sender, System.EventArgs e)
{
string Filename=System.IO .Directory.GetCurrentDirectory ();//获取应用程序的当前工作目录;
Filename+="\\data\\student_data.bin";//设置路径文件为应用程序的当前工作目录(即bin\debug\)下的DATA目录下的student_data.bin;
//if(saveFileDialog1.ShowDialog ()==DialogResult.OK && saveFileDialog1.FileName !="" )
// Filename=saveFileDialog1.FileName;使用对话框时用
BinaryFormatter formatter = new BinaryFormatter();
//Stream stream = new FileStream("e:\\he\\MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);
Stream stream = new FileStream(Filename, FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, n );
for(i=0;i<n;i++)
formatter.Serialize (stream,stu[i]);
stream.Close();
}
private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton2.Checked)
textBox3.Text =radioButton2.Text ;
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Close ();
}
private void button1_Click(object sender, System.EventArgs e)
{
stu[i].Number =textBox1.Text ;
stu[i].Name =textBox2.Text ;
stu[i].sex =textBox3.Text ;
stu[i].zhenzhi=comboBox1.Text;
stu[i].birthday =dateTimePicker1.Value.ToString();
stu[i].interesting =textBox4.Text ;
i++;
n++;
textBox1.Text ="" ;
textBox2.Text ="" ;
textBox3.Text ="" ;
textBox4.Text ="" ;
comboBox1.Text ="";
textBox1.Focus ();
}
private void textBox5_TextChanged(object sender, System.EventArgs e)
{
}
private void textBox4_TextChanged(object sender, System.EventArgs e)
{
}
private void textBox3_TextChanged(object sender, System.EventArgs e)
{
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
if(checkBox1.Checked)
textBox4.Text+=checkBox1.Text;
}
private void label6_Click(object sender, System.EventArgs e)
{
}
private void label5_Click(object sender, System.EventArgs e)
{
}
private void label7_Click(object sender, System.EventArgs e)
{
}
private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e)
{
}
private void textBox2_TextChanged(object sender, System.EventArgs e)
{
}
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
if(checkBox2.Checked)
textBox4.Text+=checkBox2.Text;
}
private void checkBox3_CheckedChanged(object sender, System.EventArgs e)
{
if(checkBox3.Checked)
textBox4.Text+=checkBox3.Text;
}
private void StuImfo_Load(object sender, System.EventArgs e)
{
stu=new Student[30];
i=0;
textBox4.Text="";
}
private void button4_Click(object sender, System.EventArgs e)
{
textBox5.Text="学号:"+textBox1.Text+"\r\n"+"姓名:"+textBox2.Text+"\r\n"+"年龄:"+textBox3.Text+"\r\n"+"政治面目:"+comboBox1.Text+"\r\n"+"爱好:"+textBox4.Text+"\r\n"+"出生年月:"+dateTimePicker1.Value.ToString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -