DevExpress实现为TextEdit设置水印文字的方法
作者:shichen2014 时间:2021-11-11 14:27:32
本文实例展示了DevExpress实现为TextEdit设置水印文字的方法,是一个很实用的技巧。分享给大家供大家参考。
关键代码如下:
public static void SetWatermark(this TextEdit textEdit, string watermark)
{
textEdit.Properties.NullValuePromptShowForEmptyValue = true;
textEdit.Properties.NullValuePrompt = watermark;
}
public static void ClearWatermark(this TextEdit textEdit)
{
if (textEdit.Properties.NullValuePromptShowForEmptyValue)
textEdit.Properties.NullValuePrompt = string.Empty;
}
测试代码如下:
private void Form1_Load(object sender, EventArgs e)
{
textEdit1.SetWatermark("请输入用户名称....");
textEdit2.SetWatermark("请输入用户密码....");
}
private void simpleButton1_Click(object sender, EventArgs e)
{
textEdit1.ClearWatermark();
textEdit2.ClearWatermark();
}
代码效果如下图所示:
标签:DevExpress,TextEdit,水印
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
基于Apache组件分析对象池原理的实现案例分析
2023-11-05 16:55:57
![](https://img.aspxhome.com/file/2023/2/99742_0s.png)
Maven入门之使用Nexus搭建Maven私服及上传下载jar包
2022-05-06 20:47:43
![](https://img.aspxhome.com/file/2023/6/61656_0s.jpg)
java设计模式之适配器模式
2021-08-28 09:08:09
![](https://img.aspxhome.com/file/2023/4/59854_0s.jpg)
SpringBoot整合activemq的案例代码
2023-11-06 18:41:37
![](https://img.aspxhome.com/file/2023/9/58589_0s.png)
Java中异常处理之try和catch代码块的使用
2021-11-21 13:30:23
详解@ConfigurationProperties实现原理与实战
2023-11-24 05:19:26
![](https://img.aspxhome.com/file/2023/7/58997_0s.png)
java map中相同的key保存多个value值方式
2022-12-12 20:05:45
SpringBoot LocalDateTime格式转换方案详解(前端入参)
2022-01-05 06:48:03
![](https://img.aspxhome.com/file/2023/9/84269_0s.png)
腾讯开源消息中间件TubeMQ总体介绍分析
2022-06-21 05:10:03
![](https://img.aspxhome.com/file/2023/0/83050_0s.png)
Java与Oracle实现事务(JDBC事务)实例详解
2023-02-12 12:47:22
搭建MyBatis-Plus框架并进行数据库增删改查功能
2023-11-09 04:33:43
![](https://img.aspxhome.com/file/2023/7/59167_0s.png)
Android EditText自定义样式的方法
2021-10-06 22:37:37
![](https://img.aspxhome.com/file/2023/0/117060_0s.jpg)
Android 通过SQLite数据库实现数据存储管理
2023-09-28 11:31:59
![](https://img.aspxhome.com/file/2023/1/86741_0s.png)
Android实现关机后数据不会丢失问题
2021-06-08 18:54:47
![](https://img.aspxhome.com/file/2023/1/104661_0s.jpg)
Android实现手机振动设置的方法
2021-08-02 23:46:21
![](https://img.aspxhome.com/file/2023/3/97853_0s.png)
java实战之桌球小游戏
2022-04-22 20:40:13
![](https://img.aspxhome.com/file/2023/6/66986_0s.jpg)
IDEA JeeSite框架httpSession.invalidate()无效问题解决方案
2023-09-23 19:44:24
C#实现打字小游戏
2023-11-08 01:08:04
![](https://img.aspxhome.com/file/2023/2/88402_0s.jpg)
WPF实现3D翻牌式倒计时特效
2021-11-11 16:08:21
![](https://img.aspxhome.com/file/2023/0/87050_0s.gif)
C#正则表达式实用大全(建议收藏!)
2023-08-29 20:23:58
![](https://img.aspxhome.com/file/2023/4/96404_0s.gif)