Last post Sep 09, 2009 05:14 PM by paulthegreat
Jun 27, 2009 02:08 PM|cyrix|LINK
Here is my code, pretty simple. I'm creating a an excel chart with C# and assigning a new mouseup event. I have tested the event and it fires correctly on the created chart giving me the x and y coordinates relative to the entire chart sheet. However I
want to call the getChartElement method inside the click event to find which chart element was clicked on so I cant get the x and y values relative to the chart itself. However the method doesn't seem to be returning a value into the ElementID, Arg1, and Arg2 parameters
that I am passing in as references.
void createChart(string xlfilePath)
xlApp = new Excel.Application();
wBook = xlApp.Workbooks.Open(xlfilePath,
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
Excel.Chart ratingChart = (Excel.Chart)wBook.Charts.Add(Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
ratingChart.ChartType = Excel.XlChartType.xlXYScatter;
ratingChart.MouseUp += new
// Mouse up event
void ratingChart_MouseUp(int Button, int Shift, int x, int y)
int ElementID = 3; //Set to Arbitrary values to see if they change during runtime
int Arg1 = 3;
int Arg1 = 3;
Excel.Chart currentChart = (Excel.Chart)wBook.ActiveChart;
currentChart.GetChartElement(x, y, ref ElementID, ref Arg1, ref Arg2);
When running the debugger, the values of ElementID, Arg1, and Arg2 never change in value even after the getChartElement has been excecuted.
Any help with this would be appreciated.
Sep 09, 2009 05:14 PM|paulthegreat|LINK
Bumping this thread, as I'm having the same issue (but in VB.NET). Does anyone out there have a solution?