Page 1 of 1

A very simple code, but a "type mismatch" error occurred.

Posted: Sat Jul 29, 2023 5:10 pm
by 16696323
A very simple code, but a "type mismatch" error occurred. Please ask for help from experts!

The code is as follows:

Code: Select all

void Cteechartdemo2Dlg::OnBnClickedLine1()
{
	// TODO: 
	CSeries lineSeries = (CSeries)m_Teechart1.Series(0);
	lineSeries.Clear();
	for (int i = 0; i < 50; i++)
	{
		lineSeries.AddXY((double)i, rand(), NULL, NULL);
	}
}
Image

Re: A very simple code, but a "type mismatch" error occurred.

Posted: Sat Jul 29, 2023 5:58 pm
by 16696323
realife wrote:
Sat Jul 29, 2023 5:10 pm
A very simple code, but a "type mismatch" error occurred. Please ask for help from experts!

The code is as follows:

Code: Select all

void Cteechartdemo2Dlg::OnBnClickedLine1()
{
	// TODO: 
	CSeries lineSeries = (CSeries)m_Teechart1.Series(0);
	lineSeries.Clear();
	for (int i = 0; i < 50; i++)
	{
		lineSeries.AddXY((double)i, rand(), NULL, NULL);
	}
}
Image
After tracking and debugging, it was found that this error (COleException cause. code=80020005) should be resolved?

Re: A very simple code, but a "type mismatch" error occurred.

Posted: Mon Jul 31, 2023 10:34 am
by yeray
Hello,

I'm not sure what exact line of code is giving the error in that screenshot. However, if we assume there is a Line series in the Chart, I think that code should work.
If you still find problems with it, please arrange a simple example project we can run as-is to reproduce the problem here.