Question

In Windows.Forms, I was not able to reproduce the exact same TextBox border as you see it in Vista / 7 Aero. All I get is a gray rectangle instead the slightly sunken gray / blue 3d border. I tried the following methods with no success:

  • VisualStyleRenderer class
  • TextBoxRenderer class
  • Control.DrawToBitmap()
  • P/Invoke with UxTheme and friends
  • Drawing RichTextBox elements instead of TextBox ones

This problem has already been discussed here but with no solution: http://social.msdn.microsoft.com/Forums/hu-HU/winforms/thread/46e66852-b52e-420d-8fe0-b717f86ecb18

It looks like there's no obvious solution for this problem. Does anyone know how to draw the exact same border as in Aero?

Was it helpful?

Solution

It's probably not going to happen for you.

I think the VisualStyleRenderer, including the TextBoxRenderer, were more meant for the XP themes.

Even the Control.DrawToBitmap(...) function magically draws a different version from what is on the screen.

I don't have the canonical answer for this, but it's most likely a result of Microsoft moving on with WPF and leaving behind the WinForm controls with those visual themes half-baked.

The only answer to this question is to use WPF or use a 3rd party system like DevExpress (which support custom themes) if you need to "theme" all of your controls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top