private void openfileToolStripMenuItem_Click(object sender, EventArgs e) { string msg; OpenFileDialog ofdlg = new OpenFileDialog(); if (ofdlg.ShowDialog() == DialogResult.OK) { PersonalRegister newform = new PersonalRegister(); FileStream file = new FileStream(ofdlg.FileName, FileMode.Open); StreamReader sr = new StreamReader(file); newform.Show(); newform.listBox1.Items.Clear(); // name msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); newform.textBox1.Text = msg.Substring(3); // 血型 msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); if (msg.Substring(3) == "A") { newform.comboBox1.SelectedIndex = 0; } else if (msg.Substring(3) == "B") { newform.comboBox1.SelectedIndex = 1; } else if (msg.Substring(3) == "O") { newform.comboBox1.SelectedIndex = 2; } else if (msg.Substring(3) == "AB") { newform.comboBox1.SelectedIndex = 3; } // 性别 msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); if (msg.Substring(3) == "男") { newform.gender_boy.Checked = true; } if (msg.Substring(3) == "女") { newform.gender_girl.Checked = true; } // 生日 msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); //newform.dateTimePicker1.Value = DateTime.ParseExact( msg.Substring(3),"yyyy-MM-dd", CultureInfo.CurrentCulture); // 兴趣爱好 msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); if (msg.IndexOf("唱歌") != -1) { newform.checkBox1.Checked = true; } if (msg.IndexOf("爬山") != -1) { newform.checkBox2.Checked = true; } if (msg.IndexOf("看书") != -1) { newform.checkBox3.Checked = true; } if (msg.IndexOf("打球") != -1) { newform.checkBox4.Checked = true; } // 籍贯 msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); // 个人简介 msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); newform.richTextBox2.Text = msg.Substring(5); // 照片 msg = sr.ReadLine(); newform.listBox1.Items.Add(msg); if (msg.Length > 3) { newform.pictureBox1.Image = Image.FromFile(msg.Substring(3)); } } }
private void addnewitemWToolStripMenuItem_Click(object sender, EventArgs e) { PersonalRegister prform = new PersonalRegister(); prform.Show(); }