?
Solved

C# Reference Chart Series on userform from another class

Posted on 2011-09-07
1
Medium Priority
?
531 Views
Last Modified: 2012-05-12
Hi,

I'm just learning c# so believe this should not be to hard.

I have a chart on a form which when loaded a new Series called "PriceData" is created, please see the code below.

My problem is I have a class say called Class1 and I am trying to reference the Series called "PriceData" on the chart but cannot.

Any help would be great.

Thanks,

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
chartFXPair.ChartAreas.Clear();
chartFXPair.Series.Clear();
chartFXPair.Titles.Add("Blah");
ChartArea cArea = new ChartArea("Area");
cArea.AxisX.Minimum = 3;
cArea.AxisX.Maximum = 5;
cArea.AxisY.Minimum = 0;
cArea.AxisY.Maximum = 100;
chartFXPair.ChartAreas.Add(cArea);
Series seriesPrice = new Series("PriceData");
seriesPrice.ChartType = SeriesChartType.Line;
seriesPrice.ChartArea = "Area";
chartFXPair.Series.Add(seriesPrice);
seriesPrice.Points.AddXY(1, 50);
seriesPrice.Points.AddXY(2, 25);
seriesPrice.Points.AddXY(3, 70);
seriesPrice.Points.AddXY(4, 40);
}

Open in new window

0
Comment
Question by:mcs26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
AJRDev earned 2000 total points
ID: 36498701
You are declaring the series inside a private method of the Form class, which is why you can't see it outside of that method.

Declare it as public at the class level and you should be able to reference it from any instance of your form.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question