Page 1 of 1

Series.ChangeType fails when second time triggering...

Posted: Thu Feb 16, 2006 9:14 am
by 9638762
Hi Narcis and all Steema Family ..

Very simple trying :

ChangeType any series ...
Then Re-ChangeType same series..

It seems problem is related with a bug in ChangeType Method of Series..
When you run ChangeType method ,the Chart reference of series flies..
The ChangeType method runs like that :

1- All reference of Series move to new fresh series...
2- Calling of Dispose method of Old series..
3- When u dispose old series ,Chart reference flies with old series ...
4- U have got one changed type new series without Chart reference ..

Could you advice us a trick for solve out this problem temprorarly...
Thx for delicious aids..

Posted: Thu Feb 16, 2006 11:32 am
by narcis
Hi glikoz,

The code below works fine for me here. Can you please test if it work at your end and modify it so that we can reproduce the problem here?

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			Steema.TeeChart.Styles.Series s0=tChart1.Series.Add(typeof(Steema.TeeChart.Styles.Points)); 
			s0.FillSampleValues();
			
			Steema.TeeChart.Styles.Series.ChangeType(ref s0, typeof(Steema.TeeChart.Styles.Line));
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			Steema.TeeChart.Styles.Series s0=tChart1[0];

			Steema.TeeChart.Styles.Series.ChangeType(ref s0, typeof(Steema.TeeChart.Styles.Bar));
		}
Thanks in advance.

Posted: Thu Feb 16, 2006 1:04 pm
by 9638762
Hi Narcis ..U can Try this one ..

Code: Select all

 
public partial class Form1 : Form
    {
        //public List<CustomPoint> listCustom = new List<CustomPoint>();
        public CustomPoint CP;
             public Form1()
        {
            InitializeComponent();
            tChart1.Aspect.View3D = false;
        }

        private void Form1_Load(object sender, System.EventArgs e)
        {
            Line l = new Line();
            //listCustom.Add(l);
            CP = l;
            Steema.TeeChart.Styles.Series s0 = tChart1.Series.Add(l);
            s0.FillSampleValues();

            ChangeType(typeof(Steema.TeeChart.Styles.Points));
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            Steema.TeeChart.Styles.Series s0 = tChart1[0];

            ChangeType(typeof(Steema.TeeChart.Styles.Area));
            ChangeType(typeof(Steema.TeeChart.Styles.Volume));
        }
        public void ChangeType(Type type)
        {
            Series s = CP;//listCustom[0] as Series;
            Series.ChangeType(ref s, type);

        }
    }

Posted: Thu Feb 16, 2006 3:23 pm
by narcis
Hi glikoz,

The working for what you are trying to do is:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			Line l = new Line(); 
	
			CustomPoint s0 = tChart1.Series.Add(l) as CustomPoint; 
			s0.FillSampleValues();

			CP = s0; 

			ChangeType(typeof(Points));
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			CustomPoint s0 = tChart1[0] as CustomPoint; 
			CP = s0;
			ChangeType(typeof(Area)); 
			
			s0 = tChart1[0] as CustomPoint; 
			CP = s0;
			ChangeType(typeof(Volume));
		}

		public void ChangeType(Type type) 
		{ 
			Series s = CP;
			Series.ChangeType(ref s, type); 
		}

Thx

Posted: Thu Feb 16, 2006 4:05 pm
by 9638762
Thx for delicious aids Narcis..
I made small changes in your code ...
And it works as consistent..