actulizar un textbox desde otro formulario

G

Guest

hola amigos.... tengo dos formularios en los cuales desde uno de ellos quiero
poder modificar lo que lleva dentro un textbox el otro.

agradesco su colaboracion.

Marcelo
 
B

Bruce Wood

hola amigos.... tengo dos formularios en los cuales desde uno de ellos quiero
poder modificar lo que lleva dentro un textbox el otro.

agradesco su colaboracion.

Seria mejor hacer esta pregunta en microsoft.public.es.dotnet.vb.

Pero, tambien ofresco servicio de traducion, gratis. :)

The post reads:

"Hello. I have two forms, and I want to change the contents of a text
box on one form from another. Thank you for your help."

Here is a solution.

Let's call your forms form1 and form2. Say that form1 conteains
textBox1, and you want to change textBox1 from form2.

First, form2 needs a reference to form1. If form2 is going to change
something on form1, then it has to be able to get to form1. How you do
this depends very much on how the two forms are created. You would
have to give more details in order for us to provide help there.

Second, form1 should define a property that allows outsiders to modify
the contents of the text box. It is best to name the property after
what the information in the text box is, not after the text box
itself. Something like this:

public string NombreDeCliente
{
get { return this._textBox1.Text; }
set
{
if (value == null)
{
this._textBox1.Text = "";
}
else
{
this._textBox1.Text = value;
}
}
}

Then, from form2, you can do this:

form1.NombreDeCliente = "John Smith";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top