如何将图表项链接到vb.net中的datagridview?
我正在尝试获取我的图表以显示一个列图,该列图从DataGridView获取数据,该数据连接到XML。我不确定该怎么做,因为没有什么可用。
我尝试使用我的朋友代码:
'collects data from the XMl file "Financial_PLanner" then displays it onto a DataGrid
Dim MyXMlFile = "Financial_Planner.xml"
If My.Computer.FileSystem.FileExists(MyXMlFile) = True Then
DsFinancialPlanner.ReadXml(MyXMlFile)
End If
'Creats a Column Graph, The X-axis of the Graph is the Data of the first Column of the DataGrid, The Y-axis of the Graph is the Data of the Second Column of the DataGrid
graFullGraph.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column
graFullGraph.Series(0).Points.Clear()
For Count As Integer = 0 To DtabFinancialDetailsDataGridView.Rows.Count - 1
graFullGraph.Series(0).Points.AddXY(DtabFinancialDetailsDataGridView.Item(0, Count).Value, DtabFinancialDetailsDataGridView.Item(1, Count).Value)
Next
但是它显示此错误: System.ArgumentNullexception:'值不能为null。 参数名称:Xvalue'
如果有人可以帮助您,那将是很棒的!谢谢你!
I am trying to get my chart to display a column graph which gets the data from a datagridview, which is connected to an xml. I am not sure what to do exactly because there is nothing that is working.
I tried using my friends code:
'collects data from the XMl file "Financial_PLanner" then displays it onto a DataGrid
Dim MyXMlFile = "Financial_Planner.xml"
If My.Computer.FileSystem.FileExists(MyXMlFile) = True Then
DsFinancialPlanner.ReadXml(MyXMlFile)
End If
'Creats a Column Graph, The X-axis of the Graph is the Data of the first Column of the DataGrid, The Y-axis of the Graph is the Data of the Second Column of the DataGrid
graFullGraph.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column
graFullGraph.Series(0).Points.Clear()
For Count As Integer = 0 To DtabFinancialDetailsDataGridView.Rows.Count - 1
graFullGraph.Series(0).Points.AddXY(DtabFinancialDetailsDataGridView.Item(0, Count).Value, DtabFinancialDetailsDataGridView.Item(1, Count).Value)
Next
But it displays this error:
System.ArgumentNullException: 'Value cannot be null.
Parameter name: xValue'
It would be great if someone could help out with this! Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论