Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/05/2011, 10:54
eloy_ameneiros
 
Fecha de Ingreso: julio-2010
Mensajes: 93
Antigüedad: 14 años, 7 meses
Puntos: 0
Pasar daots a otro form c#

Hola a todos, mi duda es la siguiente:

quiero pasar el dato de un label de un formulario a otro, pero creo la instancia en el form2 y le paso el valor del form1, pero me llega vacío. Lo hago de la siguiente manera:

Cita:
Form1

private void Pinchar(object sender, EventArgs e)
{
Gestion_Comerciales gc = new Gestion_Comerciales();
gc.nComercial = lbl_nombre.Text;
gc.ShowDialog();
}

Form2

private string _nComercial;

public string nComercial
{
get { return _nComercial; }
set { _nComercial = value; }
}

private void CargarSeleccionada()
{
string nombre = this.nComercial;
var nombreC = from nc in s.Operadoras
where nc.Nombre == nombre
select new
{
nomComercial = nc.Nombre,
turno = nc.Turnos.Descripcion,
empresa = nc.Empresa,
nif = nc.DNI,
telf = nc.Telefono,
dir = nc.Direccion,
comentarios = nc.Comentarios
};
foreach (var op in nombreC)
{
txt_nombre.Text = op.nomComercial;
cmb_turno.SelectedItem = op.turno;
cmb_empresa.SelectedItem = op.empresa;
txt_dni.Text = op.nif;
txt_telefono.Text = op.telf;
txt_direccion.Text = op.dir;
txt_comentarios.Text = op.comentarios;
}
}