InvalidActiveXSateException was unhandled- MSChart control 6.0
-
My code is, AxMSChart20Lib.AxMSChart chart = new AxMSChart20Lib.AxMSChart(); chart.Title.Text = "My first chart"; this.Controls.Add(chart); When i use this code, i get this exception, "InvalidActiveXSateException was unhandled" Exception of type: 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown. Can u tell, how can this be corrected? Thanks-Guna
-
My code is, AxMSChart20Lib.AxMSChart chart = new AxMSChart20Lib.AxMSChart(); chart.Title.Text = "My first chart"; this.Controls.Add(chart); When i use this code, i get this exception, "InvalidActiveXSateException was unhandled" Exception of type: 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown. Can u tell, how can this be corrected? Thanks-Guna
To get rid off that exception, Just add the control first with your container before using any of it's properties or methods. AxMSChart20Lib.AxMSChart m_objChart = new AxMSChart20Lib.AxMSChart(); this.Controls.Add(m_objChart); m_objChart.Title.Text = "My first chart";