Hi,
I need to copy a graph from one Form to another (all the series, presentation, data....).
I've try with a MemoryStream but it crash at the load....
what's wrong ?
To simplify, I've try with 2 graph on the same form iwth the following code :
System.IO.MemoryStream stream = new System.IO.MemoryStream();
try
{
tChart1.Export.Template.Save(stream);
// 2) Load the template into other Chart...
stream.Position = 0;
tChart2.Import.Template.Load(stream);
// restore the chart alignment (in this example)
this.tChart2.Dock = DockStyle.Fill;
// repaint the Chart
this.tChart2.Refresh();
}
finally
{
// remove the stream, it's no longer necessary...
stream.Close();
}
This code crash at the Template.Load.
What's wrong ? I've try with the new TeeChart version with no success...
Thansk for your help.
Herve MAILLARD
How to copy a graph from one Form to another
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi ..
Using version 1.1.1644.16795, the latest public version, the following code works as expected here:
Using version 1.1.1644.16795, the latest public version, the following code works as expected here:
Code: Select all
private Steema.TeeChart.Styles.Bar bar1;
private void Form1_Load(object sender, System.EventArgs e) {
bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Random rnd = new Random();
tChart1.Aspect.View3D = false;
for(double i=1;i<=48;++i) {
bar1.Add(i,rnd.Next(100),Color.Red);
}
}
private void button1_Click(object sender, System.EventArgs e) {
System.IO.MemoryStream stream = new System.IO.MemoryStream();
try {
tChart1.Export.Template.Save(stream);
// 2) Load the template into other Chart...
stream.Position = 0;
tChart2.Import.Template.Load(stream);
// restore the chart alignment (in this example)
this.tChart2.Dock = DockStyle.Fill;
// repaint the Chart
this.tChart2.Refresh();
}
finally {
// remove the stream, it's no longer necessary...
stream.Close();
}
}
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Hi Herve,
I've posted one example (which works fine here) in the steema.public.attachments newsgroup. Could you please test it ?
I've posted one example (which works fine here) in the steema.public.attachments newsgroup. Could you please test it ?
Pep Jorge
http://support.steema.com
http://support.steema.com
Hi.
I've tried the following code and it worked just fine:
I've also posted complete VS2003 project demonstrating this at steema.public.attachments newsgroup.
I've tried the following code and it worked just fine:
Code: Select all
System.IO.MemoryStream stream = new System.IO.MemoryStream();
try
{
tChart1.Export.Template.Save(stream);
stream.Position = 0;
Form2 f = new Form2(); // target chart on different form
f.tChart1.Import.Template.Load(stream);
f.tChart1.Dock = DockStyle.Fill;
f.tChart1.Refresh();
f.Show();
}
finally
{
stream.Close();
}
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
no no no.... still doesn' t work
Hi,
I may have a problem with my .NEt config because it still doesn't work.
I've try with your code, and I get the following :
System.Reflection.TargetInvocationException: Une exception a été levée par la cible d'un appel. ---> System.InvalidCastException: L'objet doit implémenter IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Steema.TeeChart.Import.Imports.DeserializeFrom(SerializationInfo info, StreamingContext context)
at Steema.TeeChart.Chart..ctor(SerializationInfo info, StreamingContext context)
--- Fin de la trace de la pile d'exception interne ---
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at Steema.TeeChart.Import.TemplateImport.Load(Stream stream)
at Steema.TeeChart.Samples.Export_Template.button2_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Assemblys chargés **************
mscorlib
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/microsoft.net/framework/v1.0.3705/mscorlib.dll
----------------------------------------
TeeChartNetExamples
Version de l'assembly : 2.0.1644.31398
Version Win32 : 2.0.1644.31398
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/TeeChartNetExamples.exe
----------------------------------------
System.Windows.Forms
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
AxInterop.SHDocVw
Version de l'assembly : 1.1.0.0
Version Win32 : 1.1.0.0
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/AxInterop.SHDocVw.DLL
----------------------------------------
Interop.SHDocVw
Version de l'assembly : 1.1.0.0
Version Win32 : 1.1.0.0
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/Interop.SHDocVw.DLL
----------------------------------------
System.resources
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3300.0
CodeBase : file:///c:/windows/assembly/gac/system.resources/1.0.3300.0_fr_b77a5c561934e089/system.resources.dll
----------------------------------------
Accessibility
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.0
CodeBase : file:///c:/windows/assembly/gac/accessibility/1.0.3300.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------
TeeChart
Version de l'assembly : 1.0.1644.16795
Version Win32 : 1.0.1644.16795
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/TeeChart.DLL
----------------------------------------
System.Design
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.design/1.0.3300.0__b03f5f7f11d50a3a/system.design.dll
----------------------------------------
System
Version de l'assembly : 1.0.5000.0
Version Win32 : 1.1.4322.573
CodeBase : file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing.Design
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.drawing.design/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.design.dll
----------------------------------------
System.Drawing
Version de l'assembly : 1.0.5000.0
Version Win32 : 1.1.4322.573
CodeBase : file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.data/1.0.3300.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Web
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.web/1.0.3300.0__b03f5f7f11d50a3a/system.web.dll
----------------------------------------
mscorlib.resources
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3300.0
CodeBase : file:///c:/windows/assembly/gac/mscorlib.resources/1.0.3300.0_fr_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
SYSTEM.WINDOWS.FORMS.resources
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3300.0
CodeBase : file:///c:/windows/assembly/gac/system.windows.forms.resources/1.0.3300.0_fr_b77a5c561934e089/system.windows.forms.resources.dll
----------------------------------------
I may have a problem with my .NEt config because it still doesn't work.
I've try with your code, and I get the following :
System.Reflection.TargetInvocationException: Une exception a été levée par la cible d'un appel. ---> System.InvalidCastException: L'objet doit implémenter IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Steema.TeeChart.Import.Imports.DeserializeFrom(SerializationInfo info, StreamingContext context)
at Steema.TeeChart.Chart..ctor(SerializationInfo info, StreamingContext context)
--- Fin de la trace de la pile d'exception interne ---
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at Steema.TeeChart.Import.TemplateImport.Load(Stream stream)
at Steema.TeeChart.Samples.Export_Template.button2_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Assemblys chargés **************
mscorlib
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/microsoft.net/framework/v1.0.3705/mscorlib.dll
----------------------------------------
TeeChartNetExamples
Version de l'assembly : 2.0.1644.31398
Version Win32 : 2.0.1644.31398
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/TeeChartNetExamples.exe
----------------------------------------
System.Windows.Forms
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
AxInterop.SHDocVw
Version de l'assembly : 1.1.0.0
Version Win32 : 1.1.0.0
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/AxInterop.SHDocVw.DLL
----------------------------------------
Interop.SHDocVw
Version de l'assembly : 1.1.0.0
Version Win32 : 1.1.0.0
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/Interop.SHDocVw.DLL
----------------------------------------
System.resources
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3300.0
CodeBase : file:///c:/windows/assembly/gac/system.resources/1.0.3300.0_fr_b77a5c561934e089/system.resources.dll
----------------------------------------
Accessibility
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.0
CodeBase : file:///c:/windows/assembly/gac/accessibility/1.0.3300.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------
TeeChart
Version de l'assembly : 1.0.1644.16795
Version Win32 : 1.0.1644.16795
CodeBase : file:///C:/Program%20Files/Steema%20Software/TeeChart%20for%20.NET%20v1/Examples/DemoProject/bin/ExecutableDemo/TeeChart.DLL
----------------------------------------
System.Design
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.design/1.0.3300.0__b03f5f7f11d50a3a/system.design.dll
----------------------------------------
System
Version de l'assembly : 1.0.5000.0
Version Win32 : 1.1.4322.573
CodeBase : file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing.Design
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.drawing.design/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.design.dll
----------------------------------------
System.Drawing
Version de l'assembly : 1.0.5000.0
Version Win32 : 1.1.4322.573
CodeBase : file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.data/1.0.3300.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Web
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3705.288
CodeBase : file:///c:/windows/assembly/gac/system.web/1.0.3300.0__b03f5f7f11d50a3a/system.web.dll
----------------------------------------
mscorlib.resources
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3300.0
CodeBase : file:///c:/windows/assembly/gac/mscorlib.resources/1.0.3300.0_fr_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
SYSTEM.WINDOWS.FORMS.resources
Version de l'assembly : 1.0.3300.0
Version Win32 : 1.0.3300.0
CodeBase : file:///c:/windows/assembly/gac/system.windows.forms.resources/1.0.3300.0_fr_b77a5c561934e089/system.windows.forms.resources.dll
----------------------------------------