I have a program that I have added a tab control (using to following code)
with 12 tabpages, on the pages
I added AxMsChart and a Button. The button control works
fine but the AxMsChart gives an "InvalidActiveXstateException" error when
I try to add a title as ".Title.Text = "Sales". What I am I doing wrong ?
I have attached the following code:
Private Sub InitializeTabs()
Dim i As Short
Dim myMonth(24) As String
Dim monthIdx As Short
For i = 1 To 12
If myMonth(i) = pTabLayOut Then
monthIdx = i
End If
Next
Dim idx As Short = monthIdx
For i = 0 To 13
Dim myTabPage As New TabPage
Dim myMSChart As New AxMSChart
Me.TabControl1.Controls.AddRange(New Control() {myTabPage})
If i = 0 Then
Me.TabControl1.TabPages(i).Text = "MISC."
ElseIf i = 13 Then
Me.TabControl1.TabPages(i).Text = " SUM"
Else
Me.TabControl1.TabPages(i).Text = " " & myMonth(idx)
Me.TabControl1.TabPages(i).Controls.Add(New AxMSChart)
Me.TabControl1.TabPages(i).Controls.Add(New Button)
End If
idx = idx + 1
Next i
Me.TabControl1.Location = New Point(115, 10)
Me.TabControl1.Size = New Size(680, 350)
Me.ClientSize = New Size(800, 400)
End sub
Private Sub CreateCollections()
'This code will dynamically include all AxMSChart in the
'a collection at runtime.
Dim c As Control
Dim c2 As Control
Dim c3 As Control
For Each c In Me.Controls 'look
at intire form
If c.GetType() Is GetType(TabControl) Then 'find a
tabControl
For Each c2 In c.Controls
'look at all controls on tabControl
If c2.GetType() Is GetType(TabPage) Then 'find a
tabPage
For Each c3 In c2.Controls 'look
at all controls on a tabPage
If c3.GetType() Is GetType(AxMSChart) Then
'find a AxMSChart
pChartCollection.Add(c3) 'add
AxMSChart to collection
End If
If c3.GetType() Is GetType(Button) Then 'find
a listBox
pButtonCollection.Add(c3) 'add
listBox to collection
End If
Next
End If
Next
End If
Next
End Sub
This is where I receive an error.
pChartCollection(1).Title.Text = "Sales"