The following doesn't work.
class DerivedTextBox : TextBox
{
public DerivedTextBox() {
if (DesignTime) {
MyProperty = foo;
}
}
...
}
--
Bob Powell [MVP]
Visual C#, System.Drawing
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
"C# Learner" <csh...@learner.here> wrote in message
news:119a2fmn...@csharp.learner...
> The DesignMode property isn't valid in the constructor. You can detect it's
> state just about anywhere else though.
In that case, how can I achieve what I'm trying?
I just want to set a value when the control is created at design-time. I
don't want to reset this value when it's created at run-time because that
would override any value the user has set at design-time.
[Designer(typeof(DerivedTextBox.DerivedTextBoxDesigner))]
public class DerivedTextBox : System.Windows.Forms.TextBox
{
public DerivedTextBox ()
{
}
public class DerivedTextBoxDesigner :
System.Windows.Forms.Design.ControlDesigner
{
public override void OnSetComponentDefaults()
{
base.OnSetComponentDefaults();
((DerivedTextBox) this.Control).MyProperty = foo;
}
}
}
"C# Learner" <csh...@learner.here> wrote in message
news:119a2fmn...@csharp.learner...