ListBox重复项检测.doc

上传人:cl****1 文档编号:558108252 上传时间:2022-10-09 格式:DOC 页数:3 大小:72.51KB
返回 下载 相关 举报
ListBox重复项检测.doc_第1页
第1页 / 共3页
ListBox重复项检测.doc_第2页
第2页 / 共3页
ListBox重复项检测.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《ListBox重复项检测.doc》由会员分享,可在线阅读,更多相关《ListBox重复项检测.doc(3页珍藏版)》请在金锄头文库上搜索。

1、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 se

2、nder, 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 = ;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号