I want when the project is starting to create a custom event for every click event inside my textbox. Then when a new textbox will be created, automatically use this click event. I don't want to create a custom control for this. I want to assign it once from a method.
Or if it is possible to create a default constructor for all my elements without creating a custom control. For example, I don't want to create this. Cause I need to replace all my controls
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace DXApplication1
{
[ToolboxItem(true)]
public class Class1 : TextBox
{
public Class1()
{
this.Click += Class1_Click;
}
private void Class1_Click(object sender, EventArgs e)
{
Console.WriteLine("Click Event");
}
}
}
I have 1000 textboxes on my project. I don't want to add in each onclick method Is there any way to add a click event to all my textboxes in the project? I want to add just one line of code to the program. cs. Is it possible?