Vb.net datagtid控制将值传递给图表 [英] Vb.net datagtid control pass values to chart

查看:77
本文介绍了Vb.net datagtid控制将值传递给图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一项关于将datagird值传递给devexpress chartcontrol的研究。我的gridcontrol中有X和Y值。(它可以有不同的行数)由于点数不同,我想用于下一个循环。(需要在最后一个值后停止)有时我有5个值,有时是8, 12,...等。我使用下面的代码,但没有实现,也许有不同的代码。



我尝试过:



I have a study about passing datagird values to devexpress chartcontrol. I have X and Y values in my gridcontrol.(It can have different row count) I would like to use for next loop due to different point counts.(needs to stop after last value) Sometimes I have 5 values, sometimes 8, ,12,..etc. I use code below, but not achived , maybe there is a differet code.

What I have tried:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

       Dim i As Integer

       For i = 0 To DataGridView1.Rows.Count - 1

           ChartControl1.Series("Series 1").Points.Add(New SeriesPoint(DataGridView1.Item(0, i).Value, DataGridView1.Item(1, i).Value))
       Next

   End Sub

推荐答案

这里找到正确的代码,解决了问题,需要在将当前行的值添加到图表之前检查新行。要做到这一点,你可以使用DataGridView.NewRowIndex





here to find correct code, solved problem, need to check for new row before adding the values from current row to your chart. To do this you can use the DataGridView.NewRowIndex


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Dim i As Integer

    For i = 0 To DataGridView1.Rows.Count - 1
        If i <> DataGridView1.NewRowIndex Then
            ChartControl1.Series("Series 1").Points.Add(New SeriesPoint(DataGridView1.Item(0, i).Value, DataGridView1.Item(1, i).Value))
        End If
    Next

End Sub


这篇关于Vb.net datagtid控制将值传递给图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆