如何将图表项链接到vb.net中的datagridview?

发布于 2025-02-09 05:36:51 字数 1026 浏览 5 评论 0原文

我正在尝试获取我的图表以显示一个列图,该列图从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文