private void Formmain_Load(object sender, EventArgs e) { try { if (File.Exists("mainStatus.cfg")) { using (FileStream fs = new FileStream("mainStatus.cfg", FileMode.Open)) { IFormatter ft = new BinaryFormatter(); saveInfo = ft.Deserialize(fs) as mainWinInfo; this.users = saveInfo.savedNodes; foreach (userNode temp in users) { userPanel newP = new userPanel(this, temp.userName); userL.Add(newP); userId++; userList.AppendText(temp.userName + "\n"); newP.Show(); foreach (var P in userL) { P.RefreshComboBox(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void butCreat_Click(object sender, EventArgs e) { if (this.textUserName.Text == "") { MessageBox.Show("Please input the user name before create user!"); } else { //if not empty ,new user and added into userL userPanel newUser = new userPanel(this, textUserName.Text); userNode tempNode = new userNode(userId, textUserName.Text); users.Add(tempNode); userId++; userL.Add(newUser); userList.AppendText(textUserName.Text + "\n"); newUser.Show(); //clear the textBox textUserName.Text = ""; foreach (var P in userL) { P.RefreshComboBox(); } } }