我要处理的过程是这样的:1)在combobox中通过回车则下拉出从数据库中查询出本字段的所有的内容.
2)如果输入想输入的内容的拼音通过回车则相应下拉出与输入的拼音码一致的汉字内容.
3)如果输入汉字,回车后如果数据中有这样的内容则光标会跳到下一个控件.
4)输入内容如果下拉菜单中有则通过上下光标选择,选择后回车,则光标就会自动跳到下一个控件
我的代码如下,不过我的这段程序出现的问题是出现下拉后选择内容后光标不会跳到下一个控件,不知为什么?
procedure TForm2.ComboBox11KeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
//begin
if tag=0 then begin
begin
with datamodule1.adoqueryjbqk do
begin
close;
Sql.Clear;
Sql.Add('select sxmc from mingxi where sxlbid=036 and sxpy like '''+combobox11.text+'%''' );
Open;
combobox11.items.clear;
First;
while not eof do
begin
combobox11.items.add(fieldbyname('sxmc').asstring);
Next;
end;
end;
end;
if datamodule1.adoqueryjbqk.RecordCount > 0 then begin
tag := 1;
end
else
begin
tag := 0;
end;
end
else begin
tag := 0;
edit3.SetFocus;
end;
//end
// else
//key:=#0;
end ;
2)如果输入想输入的内容的拼音通过回车则相应下拉出与输入的拼音码一致的汉字内容.
3)如果输入汉字,回车后如果数据中有这样的内容则光标会跳到下一个控件.
4)输入内容如果下拉菜单中有则通过上下光标选择,选择后回车,则光标就会自动跳到下一个控件
我的代码如下,不过我的这段程序出现的问题是出现下拉后选择内容后光标不会跳到下一个控件,不知为什么?
procedure TForm2.ComboBox11KeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
//begin
if tag=0 then begin
begin
with datamodule1.adoqueryjbqk do
begin
close;
Sql.Clear;
Sql.Add('select sxmc from mingxi where sxlbid=036 and sxpy like '''+combobox11.text+'%''' );
Open;
combobox11.items.clear;
First;
while not eof do
begin
combobox11.items.add(fieldbyname('sxmc').asstring);
Next;
end;
end;
end;
if datamodule1.adoqueryjbqk.RecordCount > 0 then begin
tag := 1;
end
else
begin
tag := 0;
end;
end
else begin
tag := 0;
edit3.SetFocus;
end;
//end
// else
//key:=#0;
end ;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货