-
May 11th, 2011, 08:36 PM
#1
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 ?
-
May 12th, 2011, 02:00 AM
#2
Re: How to embed custom variable
Not sure about your question, could you please explain better?
-
May 12th, 2011, 07:50 AM
#3
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.
-
May 12th, 2011, 09:07 AM
#4
Re: How to embed custom variable
Originally Posted by darwen
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|