Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Example: TcxCustomDataSource.AppendRecord, TcxCustomDataSource.InsertRecord

Assume that you implement a custom data source from an external TStringList object (FStringList). The AppendRecord method should add a new string at the end of the list. The InsertRecord method should insert a new item in this list at the position specified by the ARecordHandle parameter by moving all following items to the end of the list. Both AppendRecord and InsertRecord should return the index of the new item as a record handle and call the DataChanged method. For information on record handles, see the TcxCustomDataSource topic.

type
  TUserDataSource = class(TcxCustomDataSource)
  private
    FStringList: TStringList;
  protected
    //...
    function AppendRecord: Pointer; override;
    function InsertRecord(ARecordHandle: Pointer): Pointer; override;
  end;
implementation
//...
function TUserDataSource.AppendRecord: Pointer;
begin
  Result := Pointer(FStringList.Add(''));
  DataChanged;
end;
function TUserDataSource.InsertRecord(ARecordHandle: Pointer): Pointer;
begin
  FStringList.Insert(Integer(ARecordHandle), '');
  Result := ARecordHandle;
  DataChanged;
end;