首页 > 解决方案 > 没有建议 TextBox.AutoComplete

问题描述

我正在尝试使用 AutoComplete 属性来获取带有建议的文本框,但当前代码不起作用

private void MainForm_Load_1(object sender, EventArgs e)
    {
        this.dataGridView1.DataSource = global.sellableItems;

        AutoCompleteStringCollection myCustomStringCollect = new AutoCompleteStringCollection();
        myCustomStringCollect.AddRange(new string[]{"Facet Hatchet",
                "Facet Fishing Rod",
                "Facet Hat of Crafting",
                "Facet Coat of Crafting",
                "Facet Gloves of Crafting",
                "Facet Trousers of Crafting",
                "Facet Boots of Crafting",
                "Facet Cap of Gathering",
                "Facet Coat of Gathering",
                "Facet Fingerless Gloves of Gathering",
                "Facet Bottoms of Gathering",
                "Facet Boots of Gathering"});
        this.textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
        this.textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
        this.textBox1.AutoCompleteCustomSource = myCustomStringCollect;
    }

编译后,我尝试了它,但它不起作用。

文本框的图像不建议任何内容

标签: c#winforms

解决方案


推荐阅读