TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
MattG
- Newbie
- Posts: 23
- Joined: Thu Jun 27, 2013 12:00 am
Post
by MattG » 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:
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;
}
Matt Garrett
CRTech
Boulder, Colorado, USA
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Thu Oct 31, 2013 2:55 pm
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,
-
MattG
- Newbie
- Posts: 23
- Joined: Thu Jun 27, 2013 12:00 am
Post
by MattG » Thu Oct 31, 2013 5:58 pm
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
Matt Garrett
CRTech
Boulder, Colorado, USA