首页 > 其他分享 >DevExpress文本编辑类控件设置水印

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

时间:2022-11-30 16:01:08浏览次数:45  
标签:控件 文本编辑 TextEdit DevExpress 水印 textEdit static Properties

为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基类

标签:控件,文本编辑,TextEdit,DevExpress,水印,textEdit,static,Properties
From: https://www.cnblogs.com/beiyougaolou/p/16938704.html

相关文章