资源预览内容
第1页 / 共3页
第2页 / 共3页
第3页 / 共3页
亲,该文档总共3页全部预览完了,如果喜欢就下载吧!
资源描述
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace Ex067 public partial class Form1 : Form public Form1() InitializeComponent(); private void btn_add_Click(object sender, EventArgs e) if (txt_add.Text = ) /文本框为空 MessageBox.Show(添加的内容不能为空!); txt_add.Focus(); /获取焦点 else if (listBox1.Items.Count 0) /判断列表框中是否有项 /循环比较是否有重复项,有则放弃添加 for (int i = 0; i listBox1.Items.Count; i+) if (string.Compare(listBox1.Itemsi.ToString(), txt_add.Text) = 0) MessageBox.Show(列表框中已有相同项,不能添加!); /提示信息 txt_add.Text = ; /清空文本框 txt_add.Focus(); return; listBox1.Items.Add(txt_add.Text.ToString(); /添加项 txt_add.Text = ; else listBox1.Items.Add(txt_add.Text.ToString(); /将文本框中的数据添加到列表框 txt_add.Text = ;
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号