文本框的联想功能

sardineany 2010-06-04 01:58:01
想要实现的功能类似于邮箱的收件人的联想,之前我用的是
this.txtMailTo.AutoCompleteCustomSource.AddRange(new string[] {"11111","y2222","33333","4444"});
this.txtMailTo.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
this.txtMailTo.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;

这个代码实现的时候,第一个收件人能联想出来,没问题。。然后我想继续联想就出不来了,可能是有些地方设置的不对。
请高人指点,谢谢了。。
...全文
966 38 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
38 条回复
切换为时间正序
请发表友善的回复…
发表回复
Binea 2011-08-15
  • 打赏
  • 举报
回复
说实话 我一看到这个标题然后在看的楼主的名字 我就知道楼猪是谁咯 嘎嘎。。。
sardineany 2010-06-07
  • 打赏
  • 举报
回复
我自己写了一个,解决了。。。
harker007 2010-06-06
  • 打赏
  • 举报
回复
关注中&&&………………
chenguoji5861 2010-06-06
  • 打赏
  • 举报
回复
这个问题很实用,还请详解,期待解决。
Gdragon123 2010-06-04
  • 打赏
  • 举报
回复
每天回帖即可获得10分可用分!
sardineany 2010-06-04
  • 打赏
  • 举报
回复
难道第一次提问就这么挂了。。。
sardineany 2010-06-04
  • 打赏
  • 举报
回复
[Quote=引用 31 楼 llddyy123wq 的回复:]
像你说的效果,直接用微软封装的方法是肯定满足不了了的。
[/Quote] 能否指点一下,我是新手。。写那个困难么?
llddyy123wq 2010-06-04
  • 打赏
  • 举报
回复
像你说的效果,直接用微软封装的方法是肯定满足不了了的。
llddyy123wq 2010-06-04
  • 打赏
  • 举报
回复
呵呵,终于明白楼主的意思了。
那样的话就不是你的的设置的问题了,而是你逻辑的问题了。
如果是这样的话,你应该重写textbox内部的筛选方法了,因为每次系统是自动拿TextBox的text值去匹配。
而照你的需求却是要拿以分号split后的最后的一个值去作为参数匹配。
要么你就做一个TextBox用户控件。变相的实现。
cp298674954 2010-06-04
  • 打赏
  • 举报
回复
this topic is very fuck
sardineany 2010-06-04
  • 打赏
  • 举报
回复
等高手指导啊。。等待中。。
sardineany 2010-06-04
  • 打赏
  • 举报
回复
[Quote=引用 25 楼 yongchaochu 的回复:]
你说的这个貌似百度都没有。。因为本身联想的机制就是从前向后匹配
[/Quote] 百度要是有我就不来这问了。。我觉得应该是有方法能实现的吧,类似邮箱收件人的功能。。
sardineany 2010-06-04
  • 打赏
  • 举报
回复
[Quote=引用 23 楼 yongchaochu 的回复:]
第一个联想出来 想联想下一个你输入的内容起码在数组中存在才能联想出来啊
[/Quote]您试一下您的程序,我第一次打1,联想出11111 ,然后打个分号,再打3的时候,就什么都联想不出来了
yongchaochu 2010-06-04
  • 打赏
  • 举报
回复
你说的这个貌似百度都没有。。因为本身联想的机制就是从前向后匹配
sardineany 2010-06-04
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 yongchaochu 的回复:]
你是想要啥效果。。。
[/Quote] 就是126的邮箱。收件人那个地方,每次输入的时候都会去找对应的联系人,刚才的方法只能满足第一个联系人,后面的联系人都联想不出来的。因为文本框里面已经有数据了
yongchaochu 2010-06-04
  • 打赏
  • 举报
回复
第一个联想出来 想联想下一个你输入的内容起码在数组中存在才能联想出来啊
sardineany 2010-06-04
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 yongchaochu 的回复:]
其中autoCompleteSource在前台设置成customsource autocompletemode设置成suggest 后台如上 就可以了
[/Quote] 我所要的效果是,第一个联想完了,然后打个分号,再次输入的时候还能够联想,也就是每次输入的时候都能够去联想,您的方法和我的实现一样,都是只能在文本框为空的时候去联想。有东西就不能联想了
yongchaochu 2010-06-04
  • 打赏
  • 举报
回复
你是想要啥效果。。。
yongchaochu 2010-06-04
  • 打赏
  • 举报
回复
前台就一个TextBox 别的什么也没有
yongchaochu 2010-06-04
  • 打赏
  • 举报
回复
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitData();

}

private void InitData()
{
AutoCompleteStringCollection autoCompleteArea = new AutoCompleteStringCollection();
autoCompleteArea.AddRange(new string[] {"11111","y2222","33333","4444"});
//this.textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
this.textBox1.AutoCompleteCustomSource = autoCompleteArea;


}

private void textBox1_TextChanged(object sender, EventArgs e)
{
//AutoCompleteStringCollection autoCompleteArea = new AutoCompleteStringCollection();
//autoCompleteArea.AddRange(new string[] { "11111", "y2222", "33333", "4444" });
////this.textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
//this.textBox1.AutoCompleteCustomSource = autoCompleteArea;
}


}
}
加载更多回复(18)

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧