可以在背景图片上一个WinForms文本框设置? [英] Can a background image be set on a Winforms TextBox?

查看:148
本文介绍了可以在背景图片上一个WinForms文本框设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能改变一个Windows窗体文本框在C#中的背景图片?没有的BackgroundImage 属性。我应覆盖油漆方法不知何故?

Is it possible to change the background image of a Windows Forms TextBox in C#? There is no BackgroundImage property. Should I override the Paint method somehow?

推荐答案

这是不可能的。如果您尝试通过在构造函数中重写TextBox和调用的SetStyle(ControlStyles.UserPaint,真正的),所以你可以重写OnPaintBackground和绘制图像,你会好粗鲁的惊喜英寸回落到传统渲染模式只是其中之一。

It isn't possible. If you try by overriding TextBox and calling SetStyle(ControlStyles.UserPaint, true) in the constructor so you can override OnPaintBackground and draw the image, you'll be in for several rude surprises. Falling back to legacy rendering mode is just one of them.

从Windows的早期日子,回来时,它仍然不得不对386SUX硬件上运行文本框的日期。它承诺在这样有限的硬件合理工作一个特别的罪行是画本身,而无需使用WM_PAINT事件。此破坏的背景图像。

TextBox dates from the very early days of Windows, back when it still had to run on 386SUX hardware. One particular crime it commits to work reasonably on such limited hardware was to draw itself without using the WM_PAINT event. This destroys the background image.

有在codeProject.com,提供了一个项目。我不能建议。

There's a project at CodeProject.com that provides one. I cannot recommend it.

这篇关于可以在背景图片上一个WinForms文本框设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆