Custom Control in TextBox Help?
public partial class PreTex开发者_开发问答tBox : TextBox
{
public PreTextBox()
{
InitializeComponent();
Text = PreText;
ForeColor = Color.Gray;
}
public string PreText
{
set;
get;
}
Text not set from PreText?
Try the following:
public partial class PreTextBox : TextBox
{
public PreTextBox()
{
InitializeComponent();
Text = PreText;
ForeColor = Color.Gray;
}
public string PreText
{
set{Text = value;}
get{return Text;}
}
}
Your code only does it once, on the constructor. You will have to write a setter for your PreText property to set the Text property as well.
Or you could just use the Text property on the TextBox that you're inheriting from and be done with it :)
精彩评论