using System.ComponentModel; namespace WinFormsControlLibrary1 { public partial class singlepattern : UserControl { [Browsable(true)] public event EventHandler UserControlClicked; public singlepattern() { InitializeComponent(); //after intialize compoment add same handler for all three controls this.Click += ControlClicked; this.label1.Click += ControlClicked; } [Browsable(true)] public Color label1BackColor { get => label1.BackColor; set => label1.BackColor = value; } [Browsable(true)] public Size label1Size { get => label1.Size; set => label1.Size = value; } private void label1_Click(object sender1, EventArgs e) { } //this method will "catch" all clicks public void ControlClicked(object sender, EventArgs e) { //raise event UserControlClicked?.Invoke(this, e); } public void UserControl_Click(object sender, EventArgs e) { } } }
"Add"
"User Control"
"Custom Control"
User Control
Custom Control
"Choose Items..."
"Choose Toolbox Items"
".NET Framework Components"
"Browse..."
"bin\Debug"
"bin\Release"
"Open"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)