有个下拉框,当在下拉框输入搜索字符h时,
下拉列表显示相应的item “hello” “head” 
输入w  item显示 “whree” “why” 
输入 why 只显示 “why”

解决方案 »

  1.   

    用list的话也就是线性查找 如果有序的话用二分?
    为什么不在数据库查询非要拿到LIST再进行判断呢?
      

  2.   

    <?xml version="1.0" encoding="utf-8" ?>
    <commands>
    <command id="1" cmd="update_traffic">
    <name>traffic1</name>
    <count control_type="text">21</count>
    <type control_type="combo" readonly="false">
    <option id="1">aa</option>
    <option id="2">bb</option>
    </type>
    <enable control_type="checkbox" />
    <help>hello update!</help>
    </command>
    <command id="2" cmd="start_traffic">
    <name control_type="text">traffic2</name>
    <help>hello start!</help>
    </command>
    <command id="3" cmd="delete_traffic">
    <name control_type="text">traffic3</name>
    <help>hello command!</help>
    </command>
    <command id="4" cmd="stop_traffic">
    <name control_type="text">traffic4</name>
    <help>hello stop!</help>
    </command>
    </commands>我是从XML中读取数据的 取出cmd放到list 
      

  3.   

    如果是web程序的话,建议用js实现,不然太慢了
      

  4.   

    有人知道Eclipse 的 Combo 关于这方面的接口 或 三方控件
      

  5.   

    既然是CS,那直接在List中搜索就可以了(或转成String[]),监听值变化事件,每次在数组中循环查找。String的startsWith(String prefix) 方法即可。相信java的String处理,效率很高的。
      

  6.   

    最好还是存DB,万一下拉框的ITEM有变动呢?
      

  7.   


    public static List<Attribute> getSortList(List<Attribute> list) {
    for (int i = 0; i < list.size(); i++) {
    for (int j = i + 1; j < list.size(); j++) {
    if (list.get(i).getValue().compareToIgnoreCase(
    list.get(j).getValue()) > 0) { // 忽略大小写
    String t = list.get(i).getValue();
    list.get(i).setValue(list.get(j).getValue());
    list.get(j).setValue(t);
    }
    }
    }

    我把List先排序了,SWT的Combo有查找的功能,不过在Combo输入什么只显示相应item 这个没实现。