有条件地阻止“确定”按钮关闭对话框
我有一个对话框,其中包含一些字段。用户应该修复稍后将被解析的表单。当用户按下“确定”时,如果检查成功,数据将进入数据库,如果没有成功,则应显示警告并保留数据对话框。如下所示:
procedure TDataSaver.OKBtnClick(Sender: TObject);
begin
if checkData then
saveDataInDatabase
else
…prevent from closing code…
end;
I have a dialog with some fields in it. The user is suppose to fix the form which will later on be parsed. When the user presses ok, the data goes to the database if the checks are successful, if not a warning should be shown and the data dialog should stay. Something like shown below:
procedure TDataSaver.OKBtnClick(Sender: TObject);
begin
if checkData then
saveDataInDatabase
else
…prevent from closing code…
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
OKBtn.ModalResult := mrNone
作为默认值并Use
OKBtn.ModalResult := mrNone
as default value and我建议您构建自己的对话框。这非常简单,一旦开始,您就可以获得您想要的内容,并在以后需要时轻松添加。
I'd recommend building your own dialog box. It is trivially easy and once you start, you can get exactly what you want and add to it later easily if needed.