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;