public void AddItemToListBox1(User user) { if (listBox1.InvokeRequired) { AddItemToListBox1Delegate d = AddItemToListBox1; listBox1.Invoke(d, user); } else { //封装成UserReminderVersion UserReminderVersion _user = new UserReminderVersion(user); int index = -1; for (int i = 0; i < listBox1.Items.Count; i++) { if (_user.Equals(listBox1.Items[i])) { index = i; _user = listBox1.Items[i] as UserReminderVersion; _user.count++; listBox1.Items.RemoveAt(i); listBox1.Items.Add(_user); break; } } if (index == -1) { listBox1.Items.Add(_user); } } }
private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { try { UserReminderVersion _user = (UserReminderVersion)listBox1.SelectedItem; User user = lwc.GetUser(_user.id); user.form.Visible = true; user.form.Activate(); RemoveItemToListBox1(user); } catch { } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if ((obj.GetType().Equals(this.GetType())) == false) { return(false); } UserReminderVersion user = (UserReminderVersion)obj; return(this.id.Equals(user.id)); }
public void RemoveItemToListBox1(User user) { if (listBox1.InvokeRequired) { RemoveItemToListBox1Delegate d = RemoveItemToListBox1; listBox1.Invoke(d, user); } else { //封装成UserReminderVersion UserReminderVersion _user = new UserReminderVersion(user); listBox1.Items.Remove(_user); listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.ClearSelected(); } }