我正在尝试以编程方式获取我的Chart对象。我已经能够使用Design文件显示Chart,但是对于我正在做的事情,我需要了解Chart Control如何以编程方式工作。这是我的代码:
Dim wavesGraph As New Chart()
Dim chartarea As New ChartArea
Dim vn1Series As New Series("VN1", SeriesChartType.Line)
wavesGraph.ChartAreas.Add(chartarea)
wavesGraph.Series.Add(vn1Series)
Console.WriteLine("Here1")
wavesGraph.ChartAreas(0).Visible = True
wavesGraph.ChartAreas(0).AxisY2.Enabled = AxisEnabled.True
wavesGraph.ChartAreas(0).AxisY.Title = "Network Voltage"
If (WavesIsI) Then
wavesGraph.ChartAreas(0).AxisY2.Title = "Network Current"
Else
wavesGraph.ChartAreas(0).AxisY2.Title = "Differential Volts"
End If
Dim rand As New Random
Console.WriteLine("Here2")
For i As Integer = 0 To 500
wavesGraph.Series(0).Points.AddXY(i, rand.Next(-255, 255))
Next
wavesGraph.Enabled = True
wavesGraph.Visible = True
Console.WriteLine("Here3")
Me.Controls.Add(wavesGraph)
上述程序不起作用。如果我将范围从0更改为166,那么它可以正常工作。
请有人帮我解决这个问题