写了个windows的小程序,在textbox中想用AutoComplete功能,但是在textbox的属性里选了AutoComplete功能,想用指定的字符串作为候选项,但是运行时却一点反映都没有,没有下拉菜单出现啊,高手请帮忙。只有20分了下面是代码编辑器编辑出的textbox的相关代码。private void InitializeComponent()
{           
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.AcceptsReturn = true;
            this.textBox1.AcceptsTab = true;
            this.textBox1.AllowDrop = true;
            this.textBox1.AutoCompleteCustomSource.AddRange(new string[] {
            "memcopy",
            "memset",
            "melloc",
            "String"});
            this.textBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.textBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
            this.textBox1.Font = new System.Drawing.Font("Times New Roman", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.textBox1.Location = new System.Drawing.Point(12, 12);
            this.textBox1.Multiline = true;
            this.textBox1.Name = "textBox1";
            this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            this.textBox1.Size = new System.Drawing.Size(639, 380);
            this.textBox1.TabIndex = 0;
            this.textBox1.WordWrap = false;
}

解决方案 »

  1.   

    AutoComplete是调用一个webservice并返回一个string[]
      

  2.   

    this.textBox1.Multiline = true;     qu  diao   kan  kan .
      

  3.   

    this.textBox1.Multiline = true;     --->  this.textBox1.Multiline = false;
      

  4.   


    你设置AutoCompleteSource 属性为CustomSource。
    但是没有指定textBox1.AutoCompleteCustomSource。
      

  5.   

    To: xjdata
    this.textBox1.Multiline = true;    --->  this.textBox1.Multiline = false;
    修改了这条就好用了,可以完成AutoComplete功能,谢谢xjdata。
    To:flyjimi
    代码中已经指定了AutoCompleteCustomSource,
    如下这段:
                this.textBox1.AutoCompleteCustomSource.AddRange(new string[] { 
                "memcopy", 
                "memset", 
                "melloc", 
                "String"});
    (感谢flyjimi)现在新的问题产生了:
    1,我想在多行输入中使用AutoComplete功能
    2,在单行模式下,只有第一个输入的字符才可以实现AutoComplete功能,不是第一个输入的就没有AutoComplete选择,但是我现在想实现在我的textbox框中输入的字符串都有AutoComplete。以上功能不能实现是因为AutoComplete就是不能实现这个功能吗?
    告诉帮忙。