uj5u.com熱心網友回復:
為啥還要求焦點不變呢?選擇完再回傳焦點不可以嗎uj5u.com熱心網友回復:
第三可以不要,我是從別的提問的人那弄過來的圖片uj5u.com熱心網友回復:
demo里有一個主從表的例子,需要設定幾個level,分別設定好對應的datasource,KEY FIELD,即可uj5u.com熱心網友回復:
1,輸入彈出輔助框,我用的是dbgrid做輔助框procedure TfmCarInfo.LabeledEdit_AddPartChange(Sender: TObject);
begin
if Trim(LabeledEdit_AddPart.Text)<>'' then
begin
ADOQuery_CodeList.Close;
ADOQuery_CodeList.SQL.Clear;
ADOQuery_CodeList.SQL.Add(' select * from part where wshortname like '+'''%'+LabeledEdit_AddPart.Text+'%''');
ADOQuery_CodeList.Open;
if ADOQuery_CodeList.RecordCount<>0 then
begin
DBGrid_PartList.Top:=LabeledEdit_AddPart.Top+LabeledEdit_AddPart.Height;
DBGrid_PartList.Left:=LabeledEdit_AddPart.Left;
DBGrid_PartList.Visible:=true;
end;
end
else
begin
DBGrid_PartList.Visible:=false;
end;
end;
2,按下鍵,移動到輔助框
procedure TfmCarInfo.LabeledEdit_AddPartKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = 40 then
begin
if (DBGrid_PartList.Visible) then
begin
DBGrid_PartList.SetFocus;
end;
end;
if key=VK_RETURN then
DBGrid_PartList.Visible:=False;
end;
procedure TfmCarInfo.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
//截獲滑鼠左鍵單擊,如果焦點不在相應的輸入框和下拉串列中,則隱藏下拉串列
if Msg.message=WM_LBUTTONUP then
begin
if (Self.ActiveControl.Name<>'LabeledEdit_AddPart')then
if (Self.ActiveControl.Name<>'DBGrid_PartList') then
DBGrid_PartList.Visible:=false;
end;
end;
procedure TfmCarInfo.ApplicationEvents1ShortCut(var Msg: TWMKey;
var Handled: Boolean);
begin
//截獲按TAB鍵事件,隱藏下拉串列
if (msg.CharCode=VK_TAB) then
begin
if Self.ActiveControl.Name='LabeledEdit_AddPart' then
DBGrid_PartList.Visible:=false;
end;
end;
uj5u.com熱心網友回復:
有沒有彈出表單的?轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/70468.html
標籤:VCL組件開發及應用
上一篇:C連載23-輸入輸出中星號的用法
下一篇:如何學習好DELPHI
