DevExpress文本编辑类控件设置水印

为TextEdit增加水印

public static class TextEditHelper
{
//设置水印值
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;
}
}
  • 上边的方法不仅适用于TextEdit,只要是文本输入类得控件都可以使用,如ComboBoxEdit、lookUpEdit等,因为其Properties属性都继承于RepositoryItemTextEdit基类

posted @   北有高楼233  阅读(192)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示