Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# Reference Chart Series on userform from another class

Posted on 2011-09-07
1
Medium Priority
?
537 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

Independent Software Vendors: 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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

609 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