110,578
社区成员
发帖
与我相关
我的任务
分享
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
if (File.Exists(@"c:\1.txt"))//路径和文件类型大家自己设置
{
StreamReader sr = new StreamReader(@"c:\1.txt", true);
string str = sr.ReadLine();
while (str != null)//判断不为空行
{
if (!this.textBox1.AutoCompleteCustomSource.Contains(str))//是否包含集合里
{
this.textBox1.AutoCompleteCustomSource.Add(str);//不包含添加
}
str = sr.ReadLine();
}
sr.Close();
}
}