如果它附加到事件,则它是触发 AfterOpen 事件的数据集。数据集本身将调用该过程,并在该参数中传递自身。
但是您添加了 Info 参数,这使得该过程作为事件处理程序无效。您希望这些信息来自哪里?来自数据集?
由于它是一个事件处理程序,因此自己调用它是一种不好的做法。您可以这样做,然后通过nil
(或特定数据集),因为它无论如何都没有使用。但是您可能会遇到奇怪的情况,因为看起来该方法只会在打开后被调用,但事实证明它也在其他场合被调用。所以最好创建一个单独的过程来做你想做的事情,并从 AfterOpen 事件处理程序中调用它。您可以从数据集中传递信息,但您也可以从其他地方调用该过程,例如在打开数据集之前提供一些初始标题:
// The procedure doesn't need the dataset, only the info to set.
procedure Tf_SeznamDluzniku.ShowInfoMessage(Info : string);
begin
l_InfoMessage.Caption := info;
end;
// The actual event handler for YourDataset.OnAfterOpen (you have to attach them)
// This can set the info, and/or maybe set the success indicator right away..
procedure Tf_SeznamDluzniku.YourDataSetAfterOpen(DataSet: TDataSet);
begin
ShowInfoMessage(DataSet.FieldByName('info').AsString);
img_success.Visible := True;
end;
// For demonstration, another event handler for showing the form, to put in some initial caption.
procedure Tf_SeznamDluzniku.FormShow(const Sender: TObject);
begin
ShowInfoMessage('Loading...');
end;