我不明白为什么无法捕获MS Chart控件抛出的异常。我使用的是带有最新更新的Visual Studio 2010。感谢你的帮助。
以下是重现问题的方法:
以下是重现问题的方法:
- Create a new WinForms application
- Add a reference to System.Windows.Forms.DataVisualization
- On the main form drop a button and a chart control
Add the following code the form's constructor
int[] x = new int[] { 1, 2, 3, 4, 5 }; int[] y = new int[] { 5, 13, 4, 10, 9 }; chart1.Series[0].Points.DataBindXY(x, y);
Add the following code to the button's click method
try { chart1.Series[0].Label = "#VAL{"; } catch { MessageBox.Show("Exception caught"); }
- Run the application
- Click the button on the form