C# System.Windows.Forms.TextBox 中的水印
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/578193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Watermark in System.Windows.Forms.TextBox
提问by Kb.
What is he best way to implement Watermark functionality for a System.Windows.Forms.TextBox
in .Net 2.0 with C#?
System.Windows.Forms.TextBox
使用 C# 在 .Net 2.0 中实现水印功能的最佳方法是什么?
Edit:
编辑:
Using the ready-made component from CodeProject was very easy. It's also with a The Code Project Open License (CPOL).
使用 CodeProject 中的现成组件非常容易。它还具有 The Code Project Open License (CPOL)。
采纳答案by Peymankh
lately I needed a watermark textbox, the first thing that popped in to my head was OnLeave and OnEnter events of textbox, but first I googled it and I got two links first was the one in CodeProject which used the System.Drawing namespace and the other one was here using the SendMessage() over here http://vidmar.net/weblog/archive/2008/11/05/watermarked-textbox-in-windows-forms-on-.net.aspx.
最近我需要一个水印文本框,第一个出现在我脑海中的是文本框的 OnLeave 和 OnEnter 事件,但首先我用谷歌搜索它,我首先得到两个链接是 CodeProject 中使用 System.Drawing 命名空间的一个和另一个一个在这里使用 SendMessage() 在这里http://vidmar.net/weblog/archive/2008/11/05/watermarked-textbox-in-windows-forms-on-.net.aspx。
I beleive the SendMessage one is much easier and it also has no flickering in it. though I used it.
我相信 SendMessage 更容易,而且它也没有闪烁。虽然我用过。
I hope it will be helpful for you.
我希望它会对你有所帮助。