Ver Mensaje Individual
  #15 (permalink)  
Antiguo 28/02/2012, 04:48
AlexFranco
 
Fecha de Ingreso: febrero-2012
Mensajes: 21
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: Pasar variable de WindowsForm a Control

He creado dos pequeños proyectos donde el problema sucede de la misma manera:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ControlesPrueba;

namespace FormPrueba
{
public partial class Form1 : Form
{

ControlDeUsuario cu = new ControlDeUsuario();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
cu.Control += new ControlDeUsuario.HandlerControl(MetodoDelEvento);
}

void MetodoDelEvento(object sender, EventArgs e)
{
textBox1.Text = "SI";
}



}
}





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ControlesPrueba
{
public partial class ControlDeUsuario : UserControl
{

public delegate void HandlerControl(object sender, EventArgs e);
public event HandlerControl Control;

public ControlDeUsuario()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (Control != null)
Control(this, e);
}

}
}