123
返回列表 发新帖
作者: 乔克斯
查看: 12079|回复: 22
打印 上一主题 下一主题

[源码] 【水印文本框】C#WinForm给控件加入水印文字

[复制链接]
21#
小口田 发表于 2017-2-21 13:06:56 | 只看该作者
感谢分享。
回复

使用道具 举报

22#
chn0000000 发表于 2017-2-21 21:51:31 | 只看该作者
复合物后和人格让我会更好
23#
Summer大大 发表于 2017-3-1 19:19:14 | 只看该作者
[C#] 纯文本查看 复制代码
public String WaterText { get; set; }
        private void textBox1_Enter(object sender, EventArgs e)
        {
            if (textBox1.Text == WaterText || textBox1.Text == "") 
            {
                textBox1.Text = "";
                textBox1.ForeColor = Color.Black;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            WaterText = "要设置的水印文字";
            textBox1.Text = WaterText;
            textBox1.ForeColor = Color.Gray;
        }

        private void textBox1_Leave(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox1.Text == WaterText)
            {
                textBox1.Text = WaterText;
                textBox1.ForeColor = Color.Gray;
            }
        }
您需要登录后才可以回帖 登录 | 加入CSkin博客

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|CSkin ( 粤ICP备13070794号

Powered by Discuz! X3.2  © 2001-2013 Comsenz Inc.  Designed by ARTERY.cn
GMT+8, 2024-5-6 06:43, Processed in 0.545188 second(s), 24 queries , Gzip On.

快速回复 返回顶部 返回列表