tags:

views:

341

answers:

2

I want to append a record in a TClientDataSet based on another record (in this same TClientDataSet). Problem is that i can't access another record in the TClientDataSet because the cursor is pointed to the row i'm appending. And i can't find another way to access the other records in the same TClientDataset.

Of course i can use an extra TClientDataSet, copy some stuff and solve it that way, but i don't like that solution.

So is there a way to access the rows/records in a TClientDataset besides moving the cursor?

+11  A: 

The only way to do this would be to fully dissect the ClientDataSet.Data property content.

Which means you will need to write most of the ClientDataSet functionality yourself.

It is much easier to clone the cursor into a new ClientDataSet, then use that cursor to browse through your records. Then you can use your old ClientDataSet to do the appends.

This article explains about cloning cursors: Cloning ClientDatSet Cursors

--jeroen

Jeroen Pluimers
A: 

You can have a look at the TClientDataSet.CloneCursor method. For more information have a look at: http://edn.embarcadero.com/article/29416

Angelos Arampatzis
Did you see Jeroen's (earlier) answer, which made the same suggestion, provided the same link, but also had more explanatory information?
Argalatyr
Don't worry; it is better to have multiple answers than none at all.
Jeroen Pluimers