namespace Wnd
{
public partial class ButtonTextBox : UserControl
{
[Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public event EventHandler ButtonClick;
[DefaultValue(false)]
public bool ReadOnly
{
get { return _ReadOnly; }
set
{
_ReadOnly = value;
OnReadOnlyChanged();
}
}
private bool _ReadOnly;
public ButtonTextBox()
{
InitializeComponent();
}
private void btnButton_Click(object sender, EventArgs e)
{
if(ButtonClick != null) // если кто-то подписался!!!
ButtonClick(sender, e);
}
protected virtual void OnReadOnlyChanged()
{
txtText.BackColor = ReadOnly ? SystemColors.Info : SystemColors.Window; // не забудь вернуть Window!!!
}
}
}