Public · Protected · Private
How to add custom Properties to a Forms control
Type: Public  |  Created: 2012-08-16  |  Frozen: Yes
« Previous Public Blog Next Public Blog »
Comments
  • Here we extend a textBox with new property

    public class MyOwntextbox : TextBox
    {
        [Bindable(false)]
        [Category("Properties")]
        [DefaultValue("")]
        [Localizable(true)]
        public string MyTipPreText 
        {// This property will be available in Properties window - design mode
            get
            {
                return tipPreText;
            }

            set
            {
                tipPreText = value;
            }
        }

        public string tipPreText;

        protected override void OnMouseHover(EventArgs e)
        {
            System.Windows.Forms.ToolTip t = new ToolTip();
            t.SetToolTip(this, tipPreText + " is my Tipss");
        }
    }

      
    2012-08-16 00:13
  • Extender classes  as above allow you to extend the functionality of a .NET control class.
    2012-08-16 00:16
This blog is frozen. No new comments or edits allowed.