Kullanıcı Denetimi özel olayları vermenin ve etkinliği kullanıcı denetimi içindeki bir olayda çağırmanın bir yolu var mı. (Çağırmak doğru terim olup olmadığından emin değilim)Winforms kullanıcı denetimleri özel olayları
public partial class Sample: UserControl
{
public Sample()
{
InitializeComponent();
}
private void TextBox_Validated(object sender, EventArgs e)
{
// invoke UserControl event here
}
}
Ve MainForm:
public partial class Sample: UserControl
{
public event EventHandler TextboxValidated;
public Sample()
{
InitializeComponent();
}
private void TextBox_Validated(object sender, EventArgs e)
{
// invoke UserControl event here
if (this.TextboxValidated != null) this.TextboxValidated(sender, e);
}
}
Ve sonra:
public partial class MainForm : Form
{
private Sample sampleUserControl = new Sample();
public MainForm()
{
this.InitializeComponent();
sampleUserControl.Click += new EventHandler(this.CustomEvent_Handler);
}
private void CustomEvent_Handler(object sender, EventArgs e)
{
// do stuff
}
}
Sen http://stackoverflow.com/questions/2151049/net-custom-event-organization-assistance –