none
Convert chart to table RRS feed

  • Question

  • Hi,

    I have a Windows Form application, which has several user selection buttons on it, and one big chart.  The chart will display many different graphs, mainly x,y spline charts.

    However, on one particular user selection, I don't want a graph, I would like the data to be displayed in a Table type.

    For example, if I have two variables Rp and Rq of say 20 values, which can be plotted on a graph.  How can I then shows these in a Table.

    Note, the plot of Rp vs Rq may not be displayed on the chart at the time of selection, e.g. the chart may be showing something else (Tp vs Tq for example)

    Rp and Rq are calculated prior to plotting them.  It is not part of a datasource, and it is not necessarily displayed on the chart.

    I understand the function DataGridView might be useful, but as I am a novice at VB, I am unclear on how best to implement it.

    Can anyone help?

    Thanks,

    Wednesday, September 5, 2012 6:31 PM

Answers

  • I didn't really manage to find a solution to display a table as such.  However, I have used chart Annotations to display the text on a white background, which is kind of what I wanted, and a suitable solution.

    The code passes the numerical data to a string array.  Since Annotations can't really hold arrays, I couldn't use a for loop, and used a do loop instead.

    Annotations can be accurately placed on the chart area, and displays the text correctly, according to the string format being used.

                Dim ip As Integer = 0
    
                Do
    
                    Dim TpAnn As New TextAnnotation
                    TpAnn.Name = ("Tp" & Convert.ToString(ip))
                    TpAnn.X = 10
                    TpAnn.Y = 17.5 + (ip * 2)
                    TpAnn.Text = Tp_str(ip)
                    TpAnn.Font = mainfont
                    TpAnn.ForeColor = Color.Navy
                    Chart1.Annotations.Add(TpAnn)
                    
                    If ip = N0 - 1 Then
                        Exit Do
                    End If
    
                    ip = ip + 1
    
                Loop

    • Marked as answer by newmanpj Thursday, September 27, 2012 11:01 AM
    Thursday, September 27, 2012 11:01 AM