Page 1 of 1

Clone a TChart

Posted: Wed Oct 30, 2013 11:56 pm
by 15666411
What is the best way to clone a TChart in C++/CLI? I've been using the following but it creates an incomplete clone. For example, the Series->XValues->Name property is reset to 'X', even though it had a custom value in the original TChart.

Here I'm cloning the TChart tc into the TChart tchart:

Code: Select all

tchart = safe_cast<TChart^>(Clone(tc));
...
System::Object^ Clone(System::Object^ apObj )
// create a deep copy of an object
{
System::IO::MemoryStream^ ms = gcnew System::IO::MemoryStream();
System::Runtime::Serialization::Formatters::Binary::BinaryFormatter^ bf = gcnew 		System::Runtime::Serialization::Formatters::Binary::BinaryFormatter();
bf->Serialize( ms, apObj );
ms->Position = 0;
System::Object^ obj = bf->Deserialize( ms );
ms->Close();
return obj;
}

Re: Clone a TChart

Posted: Thu Oct 31, 2013 2:55 pm
by 10050769
Hello MattG,

I am afraid there is a problem with Clone method, that it reset all the properties when do the copy. It is a known bug (TF02014729) for us. We will try to fix it to upcoming versions of TeeChartFor.Net. On the other hand, you can change the properties manually as a workaround, at the moment.

Thanks,

Re: Clone a TChart

Posted: Thu Oct 31, 2013 5:58 pm
by 15666411
Okay, thank you Sandra. For now I'll just update the properties I'm interested in manually. This is fine for the limited things I'm currently doing with the clone, but would not be acceptable if I needed a true clone.

Matt