summaryrefslogtreecommitdiff
path: root/extras/tiopf/demos
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-06-09 15:04:39 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-06-09 15:04:39 +0000
commit41b632bcd7c88cf1202e48b1e6ab6d746017573e (patch)
tree29e203cb915acf58f77f9cda68da50d247e56451 /extras/tiopf/demos
parentd76651d046c91a81f56416a7dac77479abaa245b (diff)
downloadfpGUI-41b632bcd7c88cf1202e48b1e6ab6d746017573e.tar.xz
* Added the Add and Delete functionality to the StringGrid Mediator Demo.
Diffstat (limited to 'extras/tiopf/demos')
-rw-r--r--extras/tiopf/demos/StringGridMediatorDemo/frm_main.pas18
1 files changed, 14 insertions, 4 deletions
diff --git a/extras/tiopf/demos/StringGridMediatorDemo/frm_main.pas b/extras/tiopf/demos/StringGridMediatorDemo/frm_main.pas
index 9f49f8d3..f82f96a6 100644
--- a/extras/tiopf/demos/StringGridMediatorDemo/frm_main.pas
+++ b/extras/tiopf/demos/StringGridMediatorDemo/frm_main.pas
@@ -76,18 +76,26 @@ begin
end;
procedure TMainForm.btnAddClicked(Sender: TObject);
+var
+ lData: TPerson;
begin
-
+ lData := TPerson.CreateNew;
+ lData.Name := 'New Name';
+ lData.Age := 12;
+ FList.Add(lData);
end;
procedure TMainForm.btnEditClicked(Sender: TObject);
begin
+ if medGrid.SelectedObject = nil then
+ Exit;
EditPerson(TPerson(medGrid.SelectedObject));
end;
procedure TMainForm.btnDeleteClicked(Sender: TObject);
begin
-
+ medGrid.SelectedObject.Deleted := True;
+ FList.NotifyObservers;
end;
procedure TMainForm.btnUpdateClicked(Sender: TObject);
@@ -112,6 +120,8 @@ var
lData: TPerson;
begin
lData := medGrid.SelectedObject as TPerson;
+ if lData = nil then
+ Exit;
edtName.Text := lData.Name;
edtAge.Text := IntToStr(lData.Age);
end;
@@ -218,7 +228,7 @@ begin
ImageName := '';
TabOrder := 7;
OnClick := @btnAddClicked;
- Enabled := False;
+// Enabled := False;
end;
btnEdit := TfpgButton.Create(self);
@@ -243,7 +253,7 @@ begin
ImageName := '';
TabOrder := 9;
OnClick := @btnDeleteClicked;
- Enabled := False;
+// Enabled := False;
end;
btnRetrieve := TfpgButton.Create(self);