TeeChart Paint Event is Not Firing

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

TeeChart Paint Event is Not Firing

Post by Quant » Wed Jun 29, 2016 12:16 pm

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();
        }
    }
}

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart Paint Event is Not Firing

Post by Narcís » Wed Jun 29, 2016 1:05 pm

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));
    }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart Paint Event is Not Firing

Post by Narcís » Tue Jul 05, 2016 8:49 am

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
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply