Hello, I am working on a simple program. But I am having trouble with MSChart and my DataGrid which is filled using an ArrayList. The problem is I cannot assign a DataGrid to the Chartdata of the chart. I think it may be my ArrayList but I'm not entirely sure how to fix it. The problem I get is a Bad Function Argument on the lineVB Code:
Chart1.ChartData = ReadingDataGrid
I'm not entirely sure why. Thanks in advance. Bye
VB Code:
Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Chart() End Sub Sub Chart() Dim patient1 As New Patient patient1.ReadingProperty = 1 patient1.ReadingValueProperty = 50 myCollection.add(patient1) patient1.ReadingProperty = 2 patient1.ReadingValueProperty = 60 myCollection.add(patient1) patient1.ReadingProperty = 3 patient1.ReadingValueProperty = 80 myCollection.add(patient1) ReadingDataGrid.SetDataBinding(myCollection.myArray, "") Chart1.ChartData = ReadingDataGrid 'Add a title and legend. With Me.Chart1 .Title.Text = "Sales" .Legend.Location.LocationType = _ MSChart20Lib.VtChLocationType.VtChLocationTypeBottom .Legend.Location.Visible = True End With 'Add titles to the axes. With Me.Chart1.Plot .Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Text = "Year" .Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = "Millions of $" End With 'Set custom colors for the bars. With Me.Chart1.Plot 'Yellow for Company A ' -1 selects all the datapoints. .SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set(250, 250, 0) 'Purple for Company B '.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set(200, 50, 200) End With End Sub End Class
VB Code:
Public Class CollectionList Public myArray As ArrayList Public Sub New() myArray = New ArrayList End Sub Public Sub Add(ByRef T As Patient) myArray.Add(T) End Sub Public Sub Remove(ByRef T As Patient) myArray.Remove(T) End Sub Public ReadOnly Property Count() As Integer Get Return myArray.Count End Get End Property Public Function GetTrack(ByVal index As Integer) As Patient Return myArray.Item(index) End Function End Class
VB Code:
Public Class Patient Private Reading As Integer Private ReadingValue As Integer Public Property ReadingProperty() As Integer Get Return Reading End Get Set(ByVal Value As Integer) Reading = Value End Set End Property Public Property ReadingValueProperty() As Integer Get Return ReadingValue End Get Set(ByVal Value As Integer) ReadingValue = Value End Set End Property End Class





Reply With Quote