Extended Textbox does not get proper forecolor!!


  • Hi there


    So Ive extended a textbox to have watermark properties and it works perfectly. I have a problem though


    Ive set my form to Segoe 9pt and forecolor 76;76;76


    My watermark textbox inherits the font alright by the forecolor is black when I input text. Even if I explicitly set the color of my watermark control to 76;76;76 when I debug thru Mybase.ForeColor is always black allready when the constructor is called. As far as I can see it should be 76;76;76 right?


    Anybody got a clue?

    Tuesday, April 17, 2007 8:34 AM


  • A control uses its parent's ForeColor when its ForeColor.IsEmpty property is True.  Sadly, TextBox disagrees with this and returns KnownColor.WindowText if the ForeColor property isn't assigned.

    If you explicitly set the ForeColor in the constructor to 76,76,76 then that's what you should get back unless the forms designer has overridden it.  Setting it explicitly with the DefaultValueAttribute is not enough.
    Tuesday, April 17, 2007 11:59 AM