I like the DragPoint tool on the chart, but I have a need where I want to give the user the option to right click or double click on a point of a series and a text box appears above the point and allows the user to enter a value in instead of dragging the point.
I can capture a double click on the chart but it is associated with the chart location and not a point. It would be most convenient if the point I could drag would have a MouseDoubleClick event I could subscribe to it.
I do have the source, maybe you could suggest some code I could add to the source that would implement this?
Thanks
How to allow a user to enter a value
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Mike,
You can easily achieve what you request using code below. You should replace the constant values I'm adding for the text boxes values.
Hope this helps!
You can easily achieve what you request using code below. You should replace the constant values I'm adding for the text boxes values.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
points1.FillSampleValues();
Steema.TeeChart.Tools.DragPoint dragPoint1 = new Steema.TeeChart.Tools.DragPoint(tChart1.Chart);
dragPoint1.Series = points1;
tChart1.DoubleClick += new EventHandler(tChart1_DoubleClick);
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
}
private int SeriesIndex = -1;
private int ValueIndex = -1;
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
for (int i = 0; i < tChart1.Series.Count; i++)
{
ValueIndex = tChart1[i].Clicked(e.X, e.Y);
if (ValueIndex != -1)
{
SeriesIndex = i;
break;
}
}
}
void tChart1_DoubleClick(object sender, EventArgs e)
{
if (SeriesIndex != -1)
{
tChart1[SeriesIndex].XValues[ValueIndex] = 5;
tChart1[SeriesIndex].YValues[ValueIndex] = 5;
tChart1[SeriesIndex].Repaint();
}
SeriesIndex = -1;
ValueIndex = -1;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |