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;
}
}
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;
}
}