1 (edited by papafrankc 2021-09-22 06:33:08)

Topic: Default setting on SAVE button

Hi All,
I have a SAVE button on most of my forms.  I have the DEFAULT setting set to FALSE for each SAVE button, because I don't want the ENTER key to exit my form before I am finished entering data.
.
However, every so often that DEFAULT setting gets reset to TRUE.
This seems to be happening whenever I edit any one of my forms.  So now I have to check each of my forms after I edit them and change that setting back to False.
.
Is this normal and is there any way I can prevent it from happening?
.
Thanks, Frank

Re: Default setting on SAVE button

Most likely this happens when creating a new form, and you simply forget to set the property to "False". It often happens with me)). Add a script that, when launched, runs through all the application forms and sets the desired property to the buttons. Below is an example of such a procedure. It works provided that all buttons for saving are named the same, for example, btnSave

procedure Init;
var
  tmpForm: TAForm;
  tmpButton: TdbButton;
  i: integer;
begin
  for i := 0 to Screen.FormCount - 1 do
  begin
    tmpForm := TAForm(Screen.Forms[i]);
    tmpButton := TdbButton( tmpForm.FindComponent('btnSave') );
    if tmpButton <> nil then
      tmpButton.Default := False;
  end;
end;

...

begin
  Init;
end.
Визуальное программирование: блог и телеграм-канал.

Re: Default setting on SAVE button

k245,
Thanks for your reply.  I was thinking that something like this might have to be done.  With your code I should be able to correct the problem.
.
I haven't been creating any new forms lately.  I've mostly been working with the same 2-3 forms and they sometimes get changed seemingly by themselves?  Strange.
.
Thanks for your help
Frank