Einzelnen Beitrag anzeigen

mcbain

Registriert seit: 18. Mai 2011
50 Beiträge
 
#8

AW: Custom Property Editor Streaming

  Alt 29. Nov 2013, 13:18
Ja, hier der Ausschnitt:
Code:
procedure TMyObject.Assign(Source: TPersistent);
begin
  if Source is TMyObject then
  begin
    FId := TMyObject (Source).FId;
  end
  else
    inherited; //raises an exception
end;

procedure TMyObject.SetID(aValue: string);
begin
  if FID <> aValue then
  begin
    FID := aValue;
    Changed(false);
  end;
end;

procedure TMyData.Notify(Item: TCollectionItem;
  Action: TCollectionNotification);
begin
  inherited;
  TMyComp(Owner).Updated;
end;

procedure TMyData.Update(Item: TCollectionItem);
begin
  inherited;
  TMyComp(Owner).Updated;
end;
Ach ja und mein Property-Editor-Formular zum Ändern der Collection sieht so aus:

Code:
procedure TMyForm.FormShow(Sender: TObject);
 if MyData <> nil then
    begin
      for i := 0 to MyData.Count -1  do
      begin
        myObject:= MyData.Items[i];
        lbx.AddItem(myObject.ClassName,myObject);
      end;
    end;
end;

procedure TMyForm.btnSaveClick(Sender: TObject);
var myObject: TMyObject;
begin
 myObject := (lbx.Items.Objects[0] as TMyObject);
 myObject .ID := '1234';
end;

Geändert von mcbain (29. Nov 2013 um 13:39 Uhr)
  Mit Zitat antworten Zitat