I am maintaining a Winforms app. My DEV machine is running XP, but my user is running Vista. Within a GroupBox I added a multiline TextBox and styled it to look like a Label by setting BackgroundColor of the Textbox to System.Control in the Visual Studio Properties of the Textbox and making the TextBox borderless. The Textbox rendered nicely in XP but on Vista the Background colour was rendered as Dark Grey instead of the colour System.Control.
To try and force Vista to render the TextBox background as the colour System.Control, I found out what the RGB Values are for the colour System.Control and set the TextBox Background to that value in the Page Load event. This did not work.
After some Googling I located a couple of posts on the issue which indicated that there is some bug relating to rendering of Multiline Textboxes in Winforms:
This self-explanatory post from Code Project, How To Make A TextBox/RichTextBox Transparent was reported by some correspondents to help them work around the Vista rendering issue.
Demetres Zarkadoulas in this Windows Developer Centre Forum post crystallized the issue: Problem With TextBoxes And Transparent Group Boxes In Vista
This seems to be a problem of the textbox in any transparent container in Vista.
Armed with hints from the links above I added a few different multiline TextBoxes with varying Properties to my Form to see which styles would render the Background Colour correctly under Vista. I found there were a several ways to solve the problem:
- Move the Multiline TextBox out of the GroupBox
- Give the TextBox a border (BorderStyle 3DBorder will do it)
- Use TransparentRichTextBox (add it to your GroupBox dynamically in Code-Behind)
- Put the TextBox on top of a Panel (This is what I ended up doing.)
So, if you’ve got a MultiLine TextBox inside a GroupBox on Vista and the Background Colour renders Dark Grey or doesn’t render to the shade you want, do any of the above.