G
Guest
Hi,
I am trying to extend a TextBox and require that I assign a default value to
it's Text property. However the problem is that the Text property will still
get the default .NET framework value (usercontrolnameXXX).
The code I am using is as follows:
public class UserControl1 : System.Windows.Forms.TextBox
{
private System.ComponentModel.Container components = null;
public UserControl1()
{
InitializeComponent();
base.Text = "red";
}
[DefaultValue("red")]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
}
The problem seems to lie within "base.Text = value", since if I comment out
that line everything works fine.
This code works perfectly for other properties so I cannot seem to
understand where the problem lies.
Any advice will be appreciated.
Thank You,
Mark Anthony Spiteri
http://blog.mspiteri.com
I am trying to extend a TextBox and require that I assign a default value to
it's Text property. However the problem is that the Text property will still
get the default .NET framework value (usercontrolnameXXX).
The code I am using is as follows:
public class UserControl1 : System.Windows.Forms.TextBox
{
private System.ComponentModel.Container components = null;
public UserControl1()
{
InitializeComponent();
base.Text = "red";
}
[DefaultValue("red")]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
}
The problem seems to lie within "base.Text = value", since if I comment out
that line everything works fine.
This code works perfectly for other properties so I cannot seem to
understand where the problem lies.
Any advice will be appreciated.
Thank You,
Mark Anthony Spiteri
http://blog.mspiteri.com