Using MsChart

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom McL.

    Using MsChart

    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 "InvalidActiveX stateException" error when
    I try to add a title as ".Title.Tex t = "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.AddRan ge(New Control() {myTabPage})

    If i = 0 Then
    Me.TabControl1. TabPages(i).Tex t = "MISC."
    ElseIf i = 13 Then
    Me.TabControl1. TabPages(i).Tex t = " SUM"
    Else
    Me.TabControl1. TabPages(i).Tex t = " " & myMonth(idx)
    Me.TabControl1. TabPages(i).Con trols.Add(New AxMSChart)
    Me.TabControl1. TabPages(i).Con trols.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 CreateCollectio ns()
    '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(TabCont rol) 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(AxMSCha rt) Then
    'find a AxMSChart
    pChartCollectio n.Add(c3) 'add
    AxMSChart to collection
    End If
    If c3.GetType() Is GetType(Button) Then 'find
    a listBox
    pButtonCollecti on.Add(c3) 'add
    listBox to collection
    End If
    Next
    End If
    Next
    End If
    Next

    End Sub

    This is where I receive an error.

    pChartCollectio n(1).Title.Text = "Sales"


  • Cor Ligthert

    #2
    Re: Using MsChart

    Tom,

    You have two times called that .Title.Text = "Sales" gives an error, however
    I don't see it in your code.

    Maybe for the next time, I find the way that you show us the problem not
    inviting to help.
    Telling that an instruction with a dot from a with goes wrong, needs to
    search for that instruction. while maybe a full instruction can be helped
    direct.

    Cor


    Comment

    Working...