DarkSoul wrote:
On Feb 26, 9:17 am, j...@auto-soft.co.za wrote:
> How can i get access to textbox or an object in another form.I need
to insert a value from a textbox on form1 into a textbox on form2 but
cant get the textbox to appear in intellisense.I am a beginner still
learning C# thanks.
you can pass the values in the constructor of form2
to add to DarkSoul's reply you need to either pass form1 or the object
you wish to talk to in as a parameter to form2 or populate an existing
value in form2
public class Form1
{
public string objectname = "";
public somemethod()
{
// Create form2 here and pass a reference to Form1 to // the
constructor of form2
Form2 frm = new Form2(this);
// or populate a property of Form2 like this
frm.somepropertyname = this; // you could also populate
this property with whatever object you wish
frm.Show();
}
}
public class Form2
{
public Form thecallingform;
public Form2(Form frm)
{
this.thecallingform = frm;
}
public void anothermethod()
{
this.thecallingform.objectname = "foo";
}
}
hope this helps