发布后,Delphi设置面板可见 [英] Delphi set Panel visible after post
问题描述
这是我的代码:
if DRelatiebeheer.ContactpersoonID.Post = Action then
KJSMDBGrid1.RefreshData;
KJPanel4.Visible := true;
我的问题是,帖子成功结束后,如何将面板设置为可见?
my question is how can i set the panel on visible when the post is succesfully ended.
我不知道如何解决它,尝试了许多方法,但是没有找到解决问题的方法.
I dont know how to fix it, tried many ways but didn't find a solution for the problem.
我认为代码不起作用,因为我将其放在 OnGetCellParams
事件上不可见.
I think the code doesn't work, because i put it invisible on the OnGetCellParams
event.
我只想设置发布信息后的最后一个面板
And I only want to set the last panel visible when the information is posted
procedure TFRelatiebeheer.KJSMDBGrid1GetCellParams(Sender: TObject);
begin
if DRelatiebeheer.ACCID.AsInteger <= 0 then
KJPanel3.Visible := false;
KJPanel4.Visible := false;
else
begin
KJPanel3.Visible := true;
end;
这是我的OnGetCellParams事件,这是另一个
this is my OnGetCellParams event, this is the other
procedure TFRelatiebeheer.SaveCancel(Sender: TObject);
begin
if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then
DRelatiebeheer.CID.Post;
DRelatiebeheer.AID.Post;
if DRelatiebeheer.CID.Post = Action then
KJSMDBGrid1.RefreshData;
KJPanel4.Visible := true;
end;
推荐答案
我认为答案可以在我对您问题的第一条评论中找到.让我们看一下这段代码:
I think the answer can be found in my first comment to your question. Let's look at this code:
procedure TFRelatiebeheer.SaveCancel(Sender: TObject);
begin
if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then
DRelatiebeheer.CID.Post;
DRelatiebeheer.AID.Post;
if DRelatiebeheer.CID.Post = Action then
KJSMDBGrid1.RefreshData;
KJPanel4.Visible := true;
end;
缩进已关闭.您认为您是在 if
中设置了 KJPanel4.Visible
,但并非如此.让我们更正缩进:
The indentation is off. You think that you are setting KJPanel4.Visible
inside the if
, but you are not. Let's correct the indentation:
procedure TFRelatiebeheer.SaveCancel(Sender: TObject);
begin
if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then
DRelatiebeheer.CID.Post;
DRelatiebeheer.AID.Post;
if DRelatiebeheer.CID.Post = Action then
KJSMDBGrid1.RefreshData;
KJPanel4.Visible := true;
end;
您看到发生了什么事吗?
Do you see what has happened?
以开始/结束
更正此错误:
procedure TFRelatiebeheer.SaveCancel(Sender: TObject);
begin
if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then
DRelatiebeheer.CID.Post;
DRelatiebeheer.AID.Post;
if DRelatiebeheer.CID.Post = Action then
begin
KJSMDBGrid1.RefreshData;
KJPanel4.Visible := true;
end;
end;
在我工作的地方,对于价值而言,我们的编码标准要求使用 begin/end 的>复合语句,并禁止使用单个语句变体.自从引入此规则以来的15年中,我们从未遇到过此错误.Niklas Wirth知道自己做错了,并纠正了Modula-2中的错误.但这很简单,只需放弃单个语句语法即可避免问题.
For what it is worth, where I work, our coding standard demands the use of compound statements, with begin/end
, and forbids the use of the single statement variant. In the past 15 years since we introduced this rule, we have not once encountered this mistake. Niklas Wirth knew that he had got it wrong and corrected the mistake in Modula-2. But it's simple enough to avoid the problem yourself just by forsaking single statement syntax.
更新,如果DRelatiebeheer.CID.Post =操作,则
看起来可疑.老实说,我对您用来推荐该问题的解决方案的类了解不足.
Update, as you and others point out, if DRelatiebeheer.CID.Post = Action then
looks dubious. I honestly don't know enough about the classes that you are using to recommend a solution to that problem.
这篇关于发布后,Delphi设置面板可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!