Series.Cursor and TChart.Cursor

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
greggL
Newbie
Newbie
Posts: 5
Joined: Mon Sep 17, 2012 12:00 am

Series.Cursor and TChart.Cursor

Post by greggL » Thu Sep 20, 2012 12:42 am

Hello,
I would like to set the Series.Cursor to something different than default, so that when I mouse over the series, the mouse cursor will change. When I try to do this, as I mouse over the series, the Chart.Cursor gets changed. When the mouse leaves the series, the cursor remains in the changed state. If I try to change the Chart.Cursor back to the original using the Series.MouseLeave event, then the cursor changes briefly, but then some other event reverts it back to the changed state.

For example if I have chart1 and series1, and I want the mouse cursor to change from Arrow to Hand as I mouse over series1, the following happens:
Set series1.Cursor = Cursors.Hand
Set chart1.Cursor = Curosor.Arrow
Mouse over chart1 and cursor is an Arrow
Mouse over series1 and the cursor changes to Hand
At this point, the chart1.Cursor has been changed to Hand (How? Why?)
When the mouse leaves series1, the cursor remains Hand
If I try to use series1.MouseLeave to set chart1.Cursor = Arrow, it will momentarily change to Arrow, then immediately change back to Hand

What should I do?

I'm using TeeChart for .NET 2011 4.1.2011.10190

Thanks,
Gregg

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Series.Cursor and TChart.Cursor

Post by Sandra » Thu Sep 20, 2012 11:26 am

Hello greggL,

I think would be more easy for you use MouseMove instead use MouseOver and do something as next code:

Code: Select all

          public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Line line1;

        private void InitializeChart()
        {
            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line1.FillSampleValues();

            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
        }

        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (line1.Clicked(e.X, e.Y) != -1)
            {
                tChart1.Cursor = Cursors.Hand;
            }
            else
            {
                tChart1.Cursor = Cursors.Arrow;
            }
        }
Can you tell us if previous code help you to solve your problem? If you have any problems please let me know.

Thanks,
Best Regards,
Sandra Pazos / 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

greggL
Newbie
Newbie
Posts: 5
Joined: Mon Sep 17, 2012 12:00 am

Re: Series.Cursor and TChart.Cursor

Post by greggL » Thu Sep 20, 2012 6:22 pm

Hi, thanks for the suggestion. The example I described was a simplified version to illustrate my problem. In reality I will be dynamically adding and removing (possibly many) series, and I would like to have different cursors depending on the series and context. I have a wrapper class for the series that handles the data being plotted and its display properties depending on the context. Therefore, it would be most convenient if I could handle the cursor at the series level. Alternatively, I also have a wrapper class for the chart, and I can handle the cursor changes at this level. However, I would like to handle this via the series events rather than chart events, so that I can pass series-specific data via the event args.

Forgive me if my description is confusing, here is a summary of my questions:
Can you explain how the Series.Cursor and Chart.Cursor are connected, and what are the event sequences that handle changing the cursor? I don't understand how changing the Series.Cursor property affects the Chart.Cursor property. I also don't know which event is stepping on my change when I try to use the series.MouseLeave event to change the Chart.Cursor.

Thanks again.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Series.Cursor and TChart.Cursor

Post by Sandra » Fri Sep 21, 2012 9:51 am

Hello greggL,

Thanks for your explanation. In this case, I inform you that in the version of TeeChart you are using, there is a bug number (TF02015929) of Series.Cursor thant causes your problem. This bug is fixed in posteriors versions, concretely in version build 4.1.2012.01030 of 3rd January 2012. I recommend you update your version of TeeChartFor.Net to last version, if you want Series.Cursor works in your end. Moreover, you can achieve do as you want in easy way without necessity of change cursor in the events of Series, because, if you assign a cursor to Series.Cursor, it changes automatically when you pass the mouse above the series, as do in next lines of code:

Code: Select all

 private void InitializeChart()
          {
              line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
              line1.FillSampleValues();
              line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
              line2.FillSampleValues();
              line1.Cursor = Cursors.Hand;
              line2.Cursor = Cursors.Cross;
}
On the other hand, if you don't want update your version, the only solution you have to achieve cursor works in your end, is using tChart1.Cursor.

I hope will helps and if you have any problems,please, let me know.

Thanks,
Best Regards,
Sandra Pazos / 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

greggL
Newbie
Newbie
Posts: 5
Joined: Mon Sep 17, 2012 12:00 am

Re: Series.Cursor and TChart.Cursor

Post by greggL » Fri Sep 21, 2012 4:15 pm

OK, thanks for the info.

Post Reply