Answered by:
Registering for Cursor events in C++ Winforms

Question
-
I'm having a struggle getting an event handler registered for picking up cursor events from MSChart in Win Forms using C++ (VS2008 SP1) (I'm seriously thinking of switching over to C#).
I've tried using the C++ equivalent of the C# sample:
this->chart1->CursorPositionChanging += gcnew System::Windows::Forms::DataVisualization::Charting::CursorEventHandler(this, &Form1::chart1_CursorPositionChanging);
but the compile kicks back with:
error C2039: 'CursorEventHandler' : is not a member of 'System::Windows::Forms::DataVisualization::Charting'
Handler code:
private: void chart1_CursorPositionChanging(System::Object^ sender, System::Windows::Forms::DataVisualization::Charting::CursorEventArgs^ e) {
}
Does anyone know how to do this in C++ ? I'd really not like to convert all of the code I've written so far on this project to C#.
Friday, March 30, 2012 1:26 PM
Answers
-
This is what I got for C# when double clicking the Chart.CursorPositionChanging event in the designer.
this.chart1.CursorPositionChanging += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CursorEventArgs>(this.chart1_CursorPositionChanging);
Looks slightly different from your code. There is no CursorEventHandler in the Charting namespace. I've no experience with C++ with .Net, so this may or may not be relevant.
Also, it has been implied that the C++ implementation of the .Net 3.5 charting component is buggy.
- Proposed as answer by siplaModerator Monday, April 2, 2012 9:48 AM
- Marked as answer by jwavilaModerator Wednesday, April 18, 2012 8:04 AM
Friday, March 30, 2012 1:51 PMModerator -
Thanks ! Turns out I should have let VS do its thing. Using the event designer as you did came up with the working code
this->chart1->CursorPositionChanging += gcnew System::EventHandler<System::Windows::Forms::DataVisualization::Charting::CursorEventArgs^ >(this, &Form1::chart1_CursorPositionChanging);
- Proposed as answer by siplaModerator Monday, April 2, 2012 9:48 AM
- Marked as answer by jwavilaModerator Wednesday, April 18, 2012 8:04 AM
Friday, March 30, 2012 2:58 PM
All replies
-
This is what I got for C# when double clicking the Chart.CursorPositionChanging event in the designer.
this.chart1.CursorPositionChanging += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CursorEventArgs>(this.chart1_CursorPositionChanging);
Looks slightly different from your code. There is no CursorEventHandler in the Charting namespace. I've no experience with C++ with .Net, so this may or may not be relevant.
Also, it has been implied that the C++ implementation of the .Net 3.5 charting component is buggy.
- Proposed as answer by siplaModerator Monday, April 2, 2012 9:48 AM
- Marked as answer by jwavilaModerator Wednesday, April 18, 2012 8:04 AM
Friday, March 30, 2012 1:51 PMModerator -
Thanks ! Turns out I should have let VS do its thing. Using the event designer as you did came up with the working code
this->chart1->CursorPositionChanging += gcnew System::EventHandler<System::Windows::Forms::DataVisualization::Charting::CursorEventArgs^ >(this, &Form1::chart1_CursorPositionChanging);
- Proposed as answer by siplaModerator Monday, April 2, 2012 9:48 AM
- Marked as answer by jwavilaModerator Wednesday, April 18, 2012 8:04 AM
Friday, March 30, 2012 2:58 PM