I have a bound chart (ie. using DataTable, and DataColumn), and I would like to save the changes done to the chart. Unfortuntately, I get a Serialization Error if I do a Template.Save("C:\TEST.TEN"). The Serialization Error refers to a DataColumn (as not being serializable).
Is there another way to save the chart preferences?
Error is as follows:
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: The type System.Data.DataColumn in Assembly System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not marked as serializable.
System.Runtime.Serialization.SerializationException
Hi, I have just started to use the .NET version of Teechart after a couple of years with the active x version and I have also come accross this error.
It seems to me that it only occurs however if one of the bound data colums is part of the primary key for the datasource.
the problem is that I need to use a primary key field as the data source, so my current workaround is to set the datasource for each series to null before attempting to serialise.
Though this works, it is not ideal so is there any info on when a fix might be implemented?
Eamon
It seems to me that it only occurs however if one of the bound data colums is part of the primary key for the datasource.
the problem is that I need to use a primary key field as the data source, so my current workaround is to set the datasource for each series to null before attempting to serialise.
Though this works, it is not ideal so is there any info on when a fix might be implemented?
Eamon
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi --
A more ideal fix would be to create a typed dataset, e.g.It seems to me that it only occurs however if one of the bound data colums is part of the primary key for the datasource.
the problem is that I need to use a primary key field as the data source, so my current workaround is to set the datasource for each series to null before attempting to serialise.
Though this works, it is not ideal so is there any info on when a fix might be implemented?
Code: Select all
private MemoryStream stream;
private Steema.TeeChart.Styles.Line line1;
private System.Data.DataTable dataTable1;
private void Form1_Load(object sender, System.EventArgs e) {
commander1.Chart = tChart1;
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
dataTable1 = new DataTable();
stream = new MemoryStream();
Random rnd = new Random();
DataColumn xValues = new DataColumn("XValues", Type.GetType("System.Double"));
DataColumn yValues = new DataColumn("YValues", Type.GetType("System.Double"));
dataTable1.Columns.Add(xValues);
dataTable1.Columns.Add(yValues);
dataTable1.PrimaryKey = new DataColumn[] {xValues};
DataRow dr;
for(double i =0; i<10; ++i) {
dr = dataTable1.NewRow();
dr[xValues] = i;
dr[yValues] = rnd.Next(100);
dataTable1.Rows.Add(dr);
}
DataSet dataSet1 = new DataSet("TeeChart_Data");
dataSet1.Tables.Add(dataTable1);
line1.DataSource = dataSet1;
line1.XValues.DataMember = dataSet1.Tables[0].Columns["XValues"].ToString();
line1.YValues.DataMember = dataSet1.Tables[0].Columns["YValues"].ToString();
// line1.DataSource = dataTable1;
// line1.XValues.DataMember = dataTable1.Columns["XValues"].ToString();
// line1.YValues.DataMember = dataTable1.Columns["YValues"].ToString();
line1.CheckDataSource();
tChart1.Export.Template.Save(stream);
stream.Position=0;
tChart2.Import.Template.Load(stream);
}
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/