DataAware Component

TECH TIP: How to Make a Data-Aware RB Component

  1. Publish the DataPipeline and DataField properties. These are declared in the ancestor class TppPrintable (ppPrnabl.pas).
  2. Override the public IsDataAware function from TppPrintable class to return True.
    function TmyDBComponent.IsDataAware: Boolean; 
    begin
      Result := True;
    
    end;
  3. Override the public Notify method from the ancestor to redraw the design control.
    procedure TmyDBComponent.Notify(aCommunicator: TppCommunicator; aOperation: TppOperationType);
    begin
    
      inherited Notify(aCommunicator, aOperation);
    
      if (aOperation in [ppopDataChange, ppopRemove]) and (pppcDesigning in DesignState) and not(Printing) then
        InvalidateDesignControl;
    
    
    end; {procedure, Notify}
  4. Override SetDataField to also redraw the design control. It is a protected method of TppPrintable.
    procedure TmyDBComponent.Notify(const Value: String);
    begin
    
      inherited SetDataField(Value);
    
      Notify(DataPipeline, ppopDataChange);