I have a form1 and form2, in form1 there is a chart which plots dot when i call a method defined in the form1 by using a button, now in form2 when i call a form1's method by passing two parameter to the method of form1 it should display dot in form1's chart , say the parameter is temperature and humidity. I hope there is a way to do this but I don't know this.Any help would be appreciated thanks in advance.
Asked
Active
Viewed 63 times
0
-
Not an exact duplicate, but extremely similar to: http://stackoverflow.com/questions/7969582/how-to-update-textbox-in-form1-from-form2 – CodingGorilla Mar 01 '16 at 14:19
1 Answers
1
First of all, you should refactor your code and separate that graph plotting method in it's separate class and then you shouldn't face this situation.
In your case, you can have a Form1
instance in your Form2
and using that instance call the method like
Public class Form2 : Form
{
public Form1 frm1 = null;
public Form2(Form1 frm)
{
this.frm1 = frm;
}
protected void btn_click(object sender, EventArgs e)
{
frm1.Plottingmethod();
}
}

Rahul
- 76,197
- 13
- 71
- 125
-
your code works perfectly however I have a small problem the plot in form1(using chart series) is not plotting the dot in form1 when I call the method in form1. The method is accessed successfully but the chart does not display dot? – LittleThunder Mar 01 '16 at 15:05