How to delete TChart (FMX, C++)


I can’t figure out how to delete a TChart. This has to be simple, but I’m not seeing it. In the TListView ButtonClick code below, I delete a series from the active TChart and, if the series happens to be the last one, then I want to delete the entire TChart.

TComponent *T; // find chart and delete the selected series
for (int i = 0; i < (Form1->ComponentCount); i++) {
T = Form1->Components[i];
if (T->ClassName() == “TChart”) {
int test = T->Tag;
if (test == TappedChartTag) { //TappedChartTag is global
if (TChart *TC = dynamic_cast<TChart *>(T)) {
TC->RemoveSeries(AItem->Index); // this removes the series
if (TC->SeriesCount()==0) { // if this was last series, delete chart

I can’t find a way to completely get rid of the TChart. The TC->CleanupInstance(); wipes it completely (nothing visible), but the TChart is still there.

I’m working in Embarcadero Rad Studio (C++ Builder 10.3 Update 1).

UPDATE: I tried delete TC; in place of that TC->CleanupInstance(); and that works on Win32 but not on iOS.

Comments are closed.