Page 1 of 1

How reuse Teegrid.Data?

Posted: Fri Dec 01, 2017 2:42 pm
by 18681439
I use grid data as: var EventsArray: TArray<tEventData>;

If I change EventsArray data out of Teegid and after make
MainForm.tgrdEvents.Data:= TVirtualData<TArray<tEventData>>.Create(EventsArray);
all was fine. (array length is same).

Only if I make:
Index:= tgrdEvents.Grid.Selected.Row;
ALength:= Length(EventsArray);
Finalize(EventsArray[Index]);
TailElements := ALength - Index;
if TailElements > 0 then
Move(EventsArray[Index + 1], EventsArray[Index], SizeOf(tEventData) * TailElements);
Initialize(EventsArray[ALength - 1]);
SetLength(EventsArray, ALength - 1); // deleting one element fom center array

MainForm.tgrdEvents.Data:= TVirtualData<TArray<tEventData>>.Create(EventsArray); -- gets access violation
and on screen no more data.

How I can reuse data array with different (longer, shooter) data size?

Harry Kalma.
Erply.

Sorry. My error. How reuse Teegrid.Data?

Posted: Fri Dec 01, 2017 3:13 pm
by 18681439
I make deleting little different al all is OK.