简体   繁体   中英

Draw TextBox border as in Vista / 7

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM