C#答复:listbox怎么删除和修改记录https://bbs.csdn.net/topics/392558231#post-403771521

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);
        //}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值