how to get an object's values from other form ?
-
Hi. im am a newbie with c#. i had created an object in one form (e.g. Form1) and i need its values from Form2. i also need the possibility to change my object's values from Form2. how do i do that ??? Thank .... Bob.:omg:
That would depend entirely on exactly what you are trying to do. If the Object is a Control you have added to the form and you know the objects name. You can access the Controls properties and methods via
for(int i = 0; i == this.ParentForm.Controls.Count-1;i += 1){ //Perform actions on registered objects. if(this.ParentForm.Controls[i].Name == "ControlName"){ //Perform actions on control. } }
However, if you need to access varibles only, you should create a static class similar to this.using System; namespace staticTest { public class Setting{ public static String[] test = new String[10]; public static int[] testInt = new int[10]; static Setting(){ } } }