zoukankan      html  css  js  c++  java
  • TextBox 文本框水印文字

     1     #region TextBox 文本框水印文字
     2     /// <summary>
     3     /// 基于.NET 2.0的TextBox工具类
     4     /// </summary>
     5     public static class TextBoxToolV2 {
     6         private const int EM_SETCUEBANNER = 0x1501;
     7         [DllImport("user32.dll", CharSet = CharSet.Auto)]
     8 
     9         private static extern Int32 SendMessage
    10          (IntPtr hWnd, int msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
    11 
    12         /// <summary>
    13         /// 为TextBox设置水印文字
    14         /// </summary>
    15         /// <param name="textBox">TextBox</param>
    16         /// <param name="watermark">水印文字</param>
    17         public static void SetWatermark(this TextBox textBox, string watermark) {
    18             SendMessage(textBox.Handle, EM_SETCUEBANNER, 0, watermark);
    19         }
    20         /// <summary>
    21         /// 清除水印文字
    22         /// </summary>
    23         /// <param name="textBox">TextBox</param>
    24         public static void ClearWatermark(this TextBox textBox) {
    25             SendMessage(textBox.Handle, EM_SETCUEBANNER, 0, string.Empty);
    26         }
    27     }
    28     
    29     #endregion
  • 相关阅读:
    函数的声明
    数组遍历的方法
    运算符
    变量命名规则
    js条件判断
    vuex使用
    高盛伦敦分部面试
    野村证券伦敦分部面试
    Linux Performance Monitoring Commands
    Linux server上too many open files问题
  • 原文地址:https://www.cnblogs.com/lyl6796910/p/5213381.html
Copyright © 2011-2022 走看看