combobox控件,只需要实现:输入A的时候,下拉框中只出现第一位是A(或者含有A)的ITEM,其他的都不显示,重新输入B的时候,同理只出现有B的。
我自己改的代码,不报错,但是不能实现筛选,各位帮忙看看,指出错误,谢谢。
unit myComBox;
interface
uses
SysUtils, Classes, Controls, StdCtrls;
type
TmyselComBox = class(TComboBox)
private
protected
public
//constructor create(aowner:tcomponent);override;
procedure change;override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('System', [TmyselComBox]);
end;
//constructor TmyselComboBox.create(aowner:tcomponent);
//begin
// inherited create(aowner);
//end;
procedure TmyselComBox.change;
var
i:integer;
stringlist1:tstrings;
stringlist2:tstrings;
begin
stringlist1:=tstringlist.Create;
stringlist2:=tstringlist.Create;
stringlist1:=Items;
for i:=0 to stringlist1.Count-1 do
if Text=stringlist1[1] then
stringlist2.Add(stringlist1);
items.AddStrings(stringlist2);
DroppedDown:=true;
inherited ;
end;
end.