将项目添加到列表框时查找项目 [英] Find items when adding items to a listbox

查看:83
本文介绍了将项目添加到列表框时查找项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们!我有个问题。如果我有一个列表框并为其添加项目



列表框:

1.一些

2 。随机

3.单词

4.我

5.写



让我们说我要添加更多的项目,如果我然后写S我希望单词Some出现在一个组合框或什么叫它,以便他们可以再次选择项目。就像webbrowser中的历史一样,当你写www时。那么你去过的网站就出现了。我怎么能这样做?

解决方案

你好,



试试这个:

  //  在构造函数中 
public Form1()
{
InitializeComponent();
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems; // 将comboBox1更改为组合框的名称
}

// 以及添加列表项的方法
listBox1.Items 。新增(comboBox1.Text);
comboBox1.Items.Add(comboBox1.Text);



希望这有帮助。


Hey guys! I have a question. If i have a listbox and add items to it like this

Listbox:
1. Some
2. Random
3. Words
4. I
5. Write

let''s say im going to add more items, if i then write S i want the word "Some" to appear in a combobox or what to call it so that they can choose the item again. Like the history in the webbrowser, when you write www. then sites you''ve visited appear. How can i do this?

解决方案

Hi,

Try this:

// in constructor
public Form1()
{
            InitializeComponent();
            comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems; // change 'comboBox1' into the name of your combo box
}

// and in the method where you add list items
listBox1.Items.Add(comboBox1.Text);
comboBox1.Items.Add(comboBox1.Text);


Hope this helps.


这篇关于将项目添加到列表框时查找项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆