You should be blowing the stack in your get accessor. When the child TextBox
Font property is queried it will attempt to return the Parent Font property
value - this is due to the Font property being an ambient property. So when
you get the TextBox Font property from within the Parent Font property, the
child attempts to get the parents value, but the parent is getting the
childs value -- stack overflow. Another way to do this is to set the Label
Font in the constructor.
public UserControl1()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
this.label1.Font = this.Font;
}
Now, since the Label Font has been explicitly set, the Label will not pick
up the Font of the parent and so the Font property will affect the TextBox
only.
If you want to override the attributes for the Font property, just make sure
that you're using the base Font to get and set.
[Category("InputBox")]
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}
--
Tim Wilson
..Net Compact Framework MVP
"pnp" <pnp.@.softlab.ntua.gr> wrote in message
news:OR**************@TK2MSFTNGP09.phx.gbl...
Tim Wilson wrote: Can you post the code for the custom property that exposes the inner
TextBox Font property?
[Category("InputBox"), Browsable(true),
RefreshProperties(RefreshProperties.None)]
public override Font Font
{
get
{
return this.textbox.Font ;
}
set
{
this.textbox.Font = value;
}
}