繁体   English   中英

Delphi10.1 Berlin .. 在打开 dblookupcombobox 菜单的情况下关闭表单时出现错误

[英]Delphi10.1 Berlin.. I get an error when I close the form with the dblookupcombobox menu open

当我关闭打开 dblookupcombobox 菜单的表单时出现错误。

错误消息: Cannot focus a disabled or invisible window

如果 dblookupcombobox 菜单未打开,则关闭表单时不会出现任何错误,当菜单仍然打开时关闭表单时会出现错误。

procedure TForm6.RzButton1Click(Sender: TObject);
begin
    with DataModule1.FDQuery6 do begin
        try
            SQL.Clear;
            SQL.Text:='insert into my_table (kayit_adi, fiyat, tarih, aciklama, list_id) values (:kayit_adi, :fiyat, :tarih, :aciklama, :list_id)';
            ParamByName('kayit_adi').Value :=DBLookupComboBox1.Text;
            ParamByName('fiyat').Value:=edit2.Text;
            ParamByName('tarih').AsDate:=RzDateTimePicker1.Date;
            ParamByName('tarih').AsDate:=RzDateTimePicker1.Date;
            ParamByName('aciklama').Value :=Edit3.Text;
            ParamByName('list_id').Value :=DBLookupComboBox1.KeyValue;
            ExecSQL;
        finally
            open ('Select * from my_table where convert(date,tarih) = convert(date, getdate());');
        end;

解决方法是使用 OnCloseQuery 事件关闭 DBLookupCombobox:

TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 
begin 
    DBLookupComboBox1.CloseUp(TRUE); 
end;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM