listbox怎么删除和修改记录https://bbs.csdn.net/topics/392558231#post-403771521
//ComboBox 下拉框 = new ComboBox();
//ListBox 项列表 = new ListBox();
//TextBox 姓名 = new TextBox(), 电话 = new TextBox();
//Button 添加 = new Button(), 删除 = new Button();
private void 微佛诞提示日历时间_Load(object sender, EventArgs e)
{
//删除.Parent = 添加.Parent = 电话.Parent = 姓名.Parent = 项列表.Parent = this;
//删除.Anchor = 添加.Anchor = 电话.Anchor = 姓名.Anchor = 项列表.Anchor = (AnchorStyles.Top | AnchorStyles.Left);
//项列表.Location = new Point(2, 2);
//电话.Location = new Point(2, 项列表.Bottom + 5);
//姓名.Location = new Point(电话.Right + 5, 项列表.Bottom + 5);
//添加.Location = new Point(2, 电话.Bottom + 5);
//删除.Location = new Point(添加.Right + 5, 电话.Bottom + 5);
//电话.Text = "电话"; 姓名.Text = "姓名"; 项列表.Items.Add("项列表"); 添加.Text = "添加"; 删除.Text = "删除";
//删除.Click += new EventHandler(删除数据);
//添加.Click += new EventHandler(添加数据);
//private void 删除数据(object sender, EventArgs e)
//{
// //if (项列表.GetSelected(项列表.SelectedIndex)) 项列表.Items.RemoveAt(项列表.SelectedIndex);
// foreach (object aa in 项列表.Items)
// if (aa.ToString().Contains(电话.Text)) { 项列表.Items.Remove(aa); break; }
// var dd = 项列表.Items.IndexOf(电话.Text + ":" + 姓名.Text);
// if (dd>=0)
// {
// 项列表.Items.Remove(项列表.Items[dd]);
// //MessageBox.Show("记录删除成功!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
// }
// else
// MessageBox.Show("用户不存在!", "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
//private void 添加数据(object sender, EventArgs e)
//{
// if (项列表.Items.IndexOf(电话.Text + ":" + 姓名.Text) < 0)
// 项列表.Items.Add(电话.Text + ":" + 姓名.Text);
// else
// MessageBox.Show("用户名已存在!", "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}