本文介绍了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

推荐答案

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控制将值传递给图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 21:29