I'm noticing some abnormalities with the CursorTool in all 2012 releases. If we set the CursorTool.XValue from code, the Cursor_Change event is not getting fired. Also setting the TeeChart's mouse cursor from code, doesn't have any effect. These were working properly until October 2011 release.
Now these issues are causing adverse effects in our existing code.
Here is the sample code:
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;
using Steema.TeeChart.Tools;
namespace SampleCode
{
public partial class Form1 : Form
{
private Steema.TeeChart.Styles.FastLine fastLine1;
private Steema.TeeChart.Tools.CursorTool cursor1;
private TextBox textBox1;
private Label label1;
private Button button1;
private FlowLayoutPanel topPanel;
public Form1()
{
InitializeComponent();
topPanel = new FlowLayoutPanel();
topPanel.Dock = DockStyle.Top;
label1 = new Label();
label1.Text = "Enter XValue:";
topPanel.Controls.Add(label1);
textBox1 = new TextBox();
topPanel.Controls.Add(textBox1);
button1 = new Button();
button1.Text = "Move CursorTool";
button1.AutoSize = true;
button1.Click += new EventHandler(button1_Click);
topPanel.Controls.Add(button1);
this.Controls.Add(topPanel);
this.Load += new EventHandler(Form1_Load);
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
fastLine1.LinePen.Width = 2;
fastLine1.FillSampleValues(20);
cursor1 = new CursorTool(tChart1.Chart);
cursor1.FollowMouse = false;
cursor1.Style = CursorToolStyles.Vertical;
cursor1.Change += new CursorChangeEventHandler(cursor1_Change);
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
tChart1.Draw();
}
void Form1_Load(object sender, EventArgs e)
{
InitializeChart();
}
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
//Even this is not working; this was working fine until October 2011 release
tChart1.Cursor = Cursors.Hand;
}
void button1_Click(object sender, EventArgs e)
{
if(!string.IsNullOrWhiteSpace(textBox1.Text))
{
//Cursor gets moved. But this should fire the cursor1_change event as well; but not happening
//This was working properly until October 2011 release
cursor1.XValue = double.Parse(textBox1.Text);
}
}
void cursor1_Change(object sender, CursorChangeEventArgs e)
{
MessageBox.Show(cursor1.XValue.ToString());
}
}
}