日期:2014-05-20 浏览次数:20902 次
Searchcombo.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event arg0) { String value=Searchcombo.getText().trim().toLowerCase(); if (Searchcombo.getItemCount()!=0) { Searchcombo.removeAll(); } //去读数据库 List<String> keys=getsss(); for (String key : keys) { if (key.indexOf(value)!=-1) { Searchcombo.add(key); System.out.println(Searchcombo.getItemCount()); } } } });
Searchcombo.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event arg0) { String value=Searchcombo.getText().trim().toLowerCase(); if (Searchcombo.getItemCount()!=0) { String[] removeItem=Searchcombo.getItems(); //循环删除下拉菜单选项 for (int i = 0; i < removeItem.length; i++) { System.out.println(removeItem[i]+"--"); Searchcombo.remove(removeItem[i]); } Searchcombo.setText(value); } List<String> keys=getsss(); for (String key : keys) { if (key.indexOf(value)!=-1) { Searchcombo.add(key); System.out.println(Searchcombo.getItemCount()); } } } });
public void handleEvent(Event arg0) { String value = searchCombo.getText().trim().toLowerCase(); String[] items = searchCombo.getItems(); int selection = searchCombo.getSelectionIndex(); String selectText; if (selection==-1) selectText = null; else selectText = searchCombo.getItem(searchCombo.getSelectionIndex()); for (int i=0; i<items.length; i++) { if (selection!=i) searchCombo.remove(items[i]); } // 去读数据库 List<String> keys = getsss(); for (String key : keys) { if (key.indexOf(value) != -1 && !key.equals(selectText)) { searchCombo.add(key); System.out.println(searchCombo.getItemCount()); } }