zoukankan      html  css  js  c++  java
  • Winform水印TextBox

    public partial class WaterTextBox : TextBox
    {
       
    private readonly Label lblwaterText = new Label();

       
    public WaterTextBox()
       {
           InitializeComponent();
           lblwaterText.BorderStyle 
    = BorderStyle.None;
           lblwaterText.Enabled 
    = false;
           lblwaterText.BackColor 
    = Color.White;
           lblwaterText.AutoSize 
    = false;
           lblwaterText.Top 
    = 1;
           lblwaterText.Left 
    = 0;
           Controls.Add(lblwaterText);
       }

       [Category(
    "扩展属性"), Description("显示的提示信息")]
       
    public string WaterText
       {
           
    get { return lblwaterText.Text; }
           
    set { lblwaterText.Text = value; }
       }

       
    public override string Text
       {
           
    set
           {
               
    if (value != string.Empty)
                   lblwaterText.Visible 
    = false;
               
    else
                   lblwaterText.Visible 
    = true;
               
    base.Text = value;
           }
           
    get { return base.Text; }
       }

       
    protected override void OnSizeChanged(EventArgs e)
       {
           
    if (Multiline && (ScrollBars == ScrollBars.Vertical || ScrollBars == ScrollBars.Both))
               lblwaterText.Width 
    = Width - 20;
           
    else
               lblwaterText.Width 
    = Width;
           lblwaterText.Height 
    = Height - 2;
           
    base.OnSizeChanged(e);
       }

       
    protected override void OnEnter(EventArgs e)
       {
           lblwaterText.Visible 
    = false;
           
    base.OnEnter(e);
       }

       
    protected override void OnLeave(EventArgs e)
       {
           
    if (base.Text == string.Empty)
               lblwaterText.Visible 
    = true;
           
    base.OnLeave(e);
       }
    }
  • 相关阅读:
    Error: unable to connect to node rabbit@mail: nodedown
    flash上传控件跨域
    Nginx配置指定媒体类型文件强制下载
    Nginx反向代理配置可跨域
    日志:using the Connector/J connection property 'autoReconnect=true' to avoid this problem
    web 安全(一)--web简介及 前端技术(js)
    Android 自动化之元素定位 xpath
    Wireshark入门
    自动化测试工具
    Android App 专项测试--压力测试篇(三)
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1562729.html
Copyright © 2011-2022 走看看