在下拉列表中搜索 [英] search in drop down list

查看:94
本文介绍了在下拉列表中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我需要在下拉列表中选择名字并使用文本框和搜索按钮。



在这种情况下,有人可以帮助我进行c#编码吗?

Hello

I need to select names in drop down list and using a text box and search button.

Can some one help me in c# coding for this case?

推荐答案

假设你的DropboownList模式下的ComboBox是'comboBox1;用于尝试匹配ComboBox中的Item的TextBox是'textBox1;触发匹配和选择尝试的按钮是'button1:



为'button1:
Assume your ComboBox in DropDownList mode is 'comboBox1; your TextBox for trying to match an Item in the ComboBox is 'textBox1; your button for triggering the attempt to match and select is 'button1:

Define a Click EventHandler for 'button1:
private void button1_Click(object sender, EventArgs e)
{
    string theString = textBox1.Text;

    if (theString == string.Empty) return;

    object strAsObject = theString as object;

    if (comboBox1.Items.Contains(strAsObject))
    {
        comboBox1.SelectedItem = strAsObject;
    }
}

我很好奇为什么你想在ComboBox中提供第二种选择项目的方法。

I am curious why you wish to provide a second means of selecting Items in the ComboBox.


ComboBox.AutoCompleteMode属性 [ ^ ]是不够的> AutoCompleteMode枚举 [ ^ ]设置为 SuggestAppend
Does ComboBox.AutoCompleteMode Property[^] isn't enough with AutoCompleteMode Enumeration[^] set to SuggestAppend?


这篇关于在下拉列表中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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