此程序使用Window应用程序设计的,此程序是作者自己建立的textbox,
他建立了AutoCompleteTextbox和CoolTextBox,用它来完成
首先我先对用户输入时出现的下拉框和匹配文字的关键字进行说明:
此程序完成匹配关键字的代码如下:
// Add some sample auto complete entry items...
this.coolTextBox1.Items.Add(new AutoCompleteEntry("Phoenix, Az", "Phoenix, Az", "Az", "PHX"));
this.coolTextBox1.Items.Add(new AutoCompleteEntry("Tempe, Az", "Tempe, Az", "Az", "TPE"));
this.coolTextBox1.Items.Add(new AutoCompleteEntry("Chandler, Az", "Chandler, Az", "Az", "CHA"));
this.coolTextBox1.Items.Add(new AutoCompleteEntry("Boxford, Ma", "Boxford, Ma", "Ma", "BXF"));
this.coolTextBox1.Items.Add(new AutoCompleteEntry("Topsfield, Ma", "Topsfield, Ma", "Ma", "TPF"));
this.coolTextBox1.Items.Add(new AutoCompleteEntry("Danvers, Ma", "Danvers, Ma", "Ma", "DNV"));
当你输入会出现下拉框,其中下拉框会出现蓝色的,此蓝色文字就是你所匹配的文字。
下面我对当你输入一个是什么么不出现匹配的关键字做说明:
此程序控制关键字的代码如下:
public class TextLengthTrigger : AutoCompleteTrigger
{
private int textLength = 2;
public int TextLength
{
get
{
return this.textLength;
}
set
{
this.textLength = value;
}
}
public TextLengthTrigger()
{
}
public TextLengthTrigger(int length)
{
this.textLength = length;
}
public override TriggerState OnTextChanged(string text)
{
if (text.Length >= this.TextLength)
return TriggerState.Show;
else if (text.Length < this.TextLength)
return TriggerState.Hide;
return TriggerState.None;
}
}
}
当你把上面的private int textLength = 2;改掉,它也不会出现一个关键字,原因是在作者改掉,是此程序出现的debug。其代码如下:
this.triggers.Add(new TextLengthTrigger(2));当你改掉这里时他就好了。
我就研究的这;
下面的研究和理解会在下面的时候呈现出来。