在这里讲一下列表框中项目与输入字符的自动匹配小功能,此功能比较简单,但相对还是很实用的
首先添加一个ListBox控件和一个Edit控件到窗体上面,设置一下ListBox的AutoComplete属性值为
True,在OnEditKeyUp事件中实现此功能,代码如下:
Procedure TForm1.EditKeyUp(Sender:Tobject;var Key:Word;shift:Tshiftstate);
var
i:integer;
Begin
For i:=1 to Length(trim(Edit.Text)) do
SenderMessage(ListBox1.Handle,WM_CHAR,integer(Edit1.Text),0);
SenderMessage(ListBox1.Handle,WM_CHAR,integer(Key),0);
end
end;
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.039914846420288 seconds