Page 1 of 1

TeeChart Paint Event is Not Firing

Posted: Wed Jun 29, 2016 12:16 pm
by 16071129
Hi,

We are not getting TeeChart's Paint Event on Runtime. For other controls Paint event is getting called successfully.

Following is the code snippet:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SampleTChart
{
    public partial class Form1 : Form
    {
        Point MouseLocation;
        public Form1()
        {
            InitializeComponent();
        }

        private void tChart1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawLine(Pens.Red, new Point(0, MouseLocation.Y), new Point(Width, MouseLocation.Y));
            e.Graphics.DrawLine(Pens.Black, new Point(MouseLocation.X, 0), new Point(MouseLocation.X, Height));      
        }

        private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            MouseLocation = e.Location;
            tChart1.Invalidate(); //or tChart1.Draw();
        }
    }
}

Re: TeeChart Paint Event is Not Firing

Posted: Wed Jun 29, 2016 1:05 pm
by narcis
Hi Quant,

I could reproduce the problem and added it Steema's bug tracker (ID1573) to be investigated. TChart object internally overrides Control.Paint event but you can use AfterDraw (TeeChart's paint event handler) instead, for example:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      var series = new Steema.TeeChart.Styles.Points(tChart1.Chart);
      series.FillSampleValues();

      //tChart1.Paint += TChart1_Paint;
      tChart1.AfterDraw += TChart1_AfterDraw;
      tChart1.MouseMove += TChart1_MouseMove;
    }

    private void TChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      g.Pen.Color = Color.Red;
      g.Line(new Point(0, MouseLocation.Y), new Point(Width, MouseLocation.Y));
      g.Pen.Color = Color.Black;
      g.Line(new Point(MouseLocation.X, 0), new Point(MouseLocation.X, Height));
    }

    private void TChart1_MouseMove(object sender, MouseEventArgs e)
    {
      MouseLocation = e.Location;
      tChart1.Invalidate(); //or tChart1.Draw();
    }

    Point MouseLocation;

    private void TChart1_Paint(object sender, PaintEventArgs e)
    {
      e.Graphics.DrawLine(Pens.Red, new Point(0, MouseLocation.Y), new Point(Width, MouseLocation.Y));
      e.Graphics.DrawLine(Pens.Black, new Point(MouseLocation.X, 0), new Point(MouseLocation.X, Height));
    }

Re: TeeChart Paint Event is Not Firing

Posted: Tue Jul 05, 2016 8:49 am
by narcis
Hi Quant,
NarcĂ­s wrote: I could reproduce the problem and added it Steema's bug tracker (ID1573) to be investigated.
An update on this issue: http://bugs.teechart.net/show_bug.cgi?id=1573#c1