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
jed@auto-soft.co.za - 26 Feb 2007 11:00 GMT
> On Feb 26, 9:17 am, j...@auto-soft.co.za wrote:
>
[quoted text clipped - 4 lines]
>
> you can pass the values in the constructor of form2
Please post example of how to do this. thank you
Pete Kane - 26 Feb 2007 11:07 GMT
> 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
[quoted text clipped - 3 lines]
>
> 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
Please post example of how to do this thank you
Do you have to write all that just to take text from a textbox on
windowsform1 to another textbox on windowsform2.I have a button on
form1 when the user clicks the button i want to transfer the text.
Sorry understand now thanks