I have two Forms Form1 and Form2, both of them are already "connected" with eachother. I am already passing button signals, trackbar values, timer ticks..., between them.
The connections looks like this inside Form1:
private void Form1_Load(object sender, EventArgs e)
{
Form2 = new Form2(timer1,btnBoost,btnBrake);
Form2.Show();
}
and inside Form2:
public Form2(Timer timer,Button Boost,Button Brake)
{
InitializeComponent();
_timer = timer;
_boost = Boost;
_brake = Brake;
}
Now I would like to pass a variable from Form1 which is changing it's value every timertick to Form2, to create a graph.
Inside Form1 it looks like this
public partial class Form1 : Form {
public double ValueThatIWant;
}
Way done im giving it a value
private void Timer1_Tick1(object sender, EventArgs e){
ValueThatIWant = Math.Sqrt(somevalue.X,somevalue.Y);
}
I've already tried to access the variable by calling Form1 from Form2
Form1.valueThatIWant
but since
public double valueThatIWant
is declared public, it's value is always 0.
private void FillChart()
{
this.chart1.Series["Velocity"].Points.AddXY(time,Form1.ValueThatIWant);
}
//That's the method I've created in Form2 to create a chart.
I would like to call the variable from inside(?) the
public Form1()
method, so that i get the changing value, and not only 0.
Hope that kinda describes my problem.
Thanks in advance!