Clone a TChart
Posted: Wed Oct 30, 2013 11:56 pm
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:
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;
}