CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    144

    How to embed custom variable

    hello , i want to make something like this

    Code:
           int i = 1;
    
                        while (thisReader.Read())
                        {
                            chart +i+ .Series.Add(thisReader.GetValue(0).ToString());
                            i++;                                                
                        }
    so i can fill chart1 , chart2 , chart3 .... as many charts as while will be executed....

    is this possible ?

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: How to embed custom variable

    Not sure about your question, could you please explain better?

  3. #3
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: How to embed custom variable

    Use an array of charts :

    Code:
    int numberOfCharts = 10;
    Chart [] charts = new Chart[numberOfCharts];
    
    // you need to populate them
    for (int index = 0; index < numberOfCharts; ++index)
    {
        charts[index] = GetChart(index);
    }
    
    while (thisReader.Read())
    {
        chart[i] .Series.Add(thisReader.GetValue(0).ToString());
        i++;                                                
    }
    If you already have chart1, chart2 etc defined (e.g. in a UI) then you can set the items of the chart array manually e.g.

    Code:
    int numberOfCharts = 10;
    Chart [] charts = new Chart[numberOfCharts];
    chart[0] = this.chart1;
    chart[1] = this.chart2;
    chart[2] = this.chart3;
    // etc
    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  4. #4
    Join Date
    Jun 2009
    Posts
    144

    Re: How to embed custom variable

    Quote Originally Posted by darwen View Post
    Use an array of charts :

    Code:
    int numberOfCharts = 10;
    Chart [] charts = new Chart[numberOfCharts];
    
    // you need to populate them
    for (int index = 0; index < numberOfCharts; ++index)
    {
        charts[index] = GetChart(index);
    }
    
    while (thisReader.Read())
    {
        chart[i] .Series.Add(thisReader.GetValue(0).ToString());
        i++;                                                
    }
    If you already have chart1, chart2 etc defined (e.g. in a UI) then you can set the items of the chart array manually e.g.

    Code:
    int numberOfCharts = 10;
    Chart [] charts = new Chart[numberOfCharts];
    chart[0] = this.chart1;
    chart[1] = this.chart2;
    chart[2] = this.chart3;
    // etc
    Darwen.
    its exactly what i want, thank you !

    EDIT:

    Code:
    using System.Windows.Forms.DataVisualization.Charting;
    
        Chart[] charts = new Chart[5];
                        charts[1] = chart1;
                        charts[2] = chart2;
                        charts[3] = chart3;
                        charts[4] = chart4;
                        charts[5] = chart5;
    Last edited by invader7; May 12th, 2011 at 09:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured