Hi!
I'm not even sure my title is correct, so please forgive me.
I have created a class that is used to set properties on controls on Form1 from other forms.
The basic process is that I have essentially created a collection of Public Variables that can be set by any form, and used by any form.
example:
The following code resides on Form1.
Real basic - straight forward class.
Form2 can read or write the value of/to LegendLocation (for example).
Form1 can then read the value and act accordingly.
What I want to do is add a function/routine that will execute when LegendLocation is changed.
Example:
Lines added are bolded.
The changeLocation(value); routine would change the location of the legend location on Form1.
I don't think this is the correct way to accomplish this, - I get an error message saying I don't have access to Form1.
I can change the protection level in the Form1 designer from private to public, but I really don't want to do that.
Can someone assist?
Thanks!
I'm not even sure my title is correct, so please forgive me.
I have created a class that is used to set properties on controls on Form1 from other forms.
The basic process is that I have essentially created a collection of Public Variables that can be set by any form, and used by any form.
example:
The following code resides on Form1.
public class PlotLegend { private string legendLocation; private string legendHorizontalPosition; private string legendVerticalPosition; private string legendVisible; public string LegendLocation { get { return this.legendLocation; } set { this.legendLocation = value; } } }
Real basic - straight forward class.
Form2 can read or write the value of/to LegendLocation (for example).
Form1 can then read the value and act accordingly.
What I want to do is add a function/routine that will execute when LegendLocation is changed.
Example:
Lines added are bolded.
public class PlotLegend { private string legendLocation; public string LegendLocation { get { return this.legendLocation; } set { this.legendLocation = value; changeLocation(value); } } private void changeLocation(string CurrentLocation) { switch(CurrentLocation) { case "Bottom": Form1.Legend1.Location = "Left"; break; case "Left": Form1.Legend1.Location = "Top"; // and so on.... } }
The changeLocation(value); routine would change the location of the legend location on Form1.
I don't think this is the correct way to accomplish this, - I get an error message saying I don't have access to Form1.
I can change the protection level in the Form1 designer from private to public, but I really don't want to do that.
Can someone assist?
Thanks!
Last edited by a moderator: