Lazarus
Programming => LCL => Topic started by: Pe3s on November 30, 2022, 09:39:32 pm
-
I wrote a code whose task is to add and edit on the same form. I wonder if it could be written better, maybe there is another solution?
Form add & edit
public
EditMode: Boolean;
OK button
with AddForm do
begin
if EditMode = True then
begin
// edit
end else
begin
//Add
end;
end;
Main form button Add
Form2.EditMode:= False;
Form2.ShowModal;
Main form button Edit
Form2.EditMode:= True;
Form2.ShowModal;
-
I wrote a code whose task is to add and edit on the same form. I wonder if it could be written better, maybe there is another solution?
You can make the form passive. In this case, the calling code uses either an existing record or creates a new one. Then it calls the edit form for this entry. And if the cancellation has passed, it deletes the new entry.
-
Thank you