From 41b632bcd7c88cf1202e48b1e6ab6d746017573e Mon Sep 17 00:00:00 2001 From: graemeg Date: Mon, 9 Jun 2008 15:04:39 +0000 Subject: * Added the Add and Delete functionality to the StringGrid Mediator Demo. --- extras/tiopf/demos/StringGridMediatorDemo/frm_main.pas | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'extras/tiopf/demos') 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); -- cgit v1.2.3-70-g09d2