1.TextBox 增加水印
新增一个用户控件,将继承UserControl改为TextBox
public partial class TextBoxEP : TextBox{public TextBoxEP(){InitializeComponent();}private const uint WT_Mark = 0x1501;[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);private string watermarkText;[Description("水印文字")]public string WatermarkText{get { return watermarkText; }set{watermarkText = value;SetWatermark(watermarkText);}}private void SetWatermark(string watermarkText){SendMessage(this.Handle, WT_Mark, 0, watermarkText);}}