zoukankan      html  css  js  c++  java
  • 重写/覆盖基类的事件

    对于从父类继承来的事件,若子类需要在触发之后,进行 一些“特殊处理时”,建议:覆盖或重写父类的 <抽闲或虚的> OnXXX函数,若还需要保留父类事件触发后的某些特性,则需要  base.OnXXX()函数。PS:这些函数 <直接> 来自父类(注:这些函数在父类中是虚函数 或 抽象函数才可以),但源头可能是更底层的基类。

     public class CCIntAndUpperLetterBox : TextBox
        {
            private string lastText = "";

            protected override void OnTextChanged(TextChangedEventArgs e)
            {
                if (Text.Length > 0)
                {
                    if (Text.Contains(" "))
                    {
                        Text = Text.Replace(" ", "");
                        SelectionStart = Text.Length;
                    }
                    else
                    {
                        if (StringHelper.IntAndUpper(Text))
                        {
                            Text = Text.ToUpper();
                            lastText = Text;
                        }
                        else
                        {
                            Text = lastText;
                        }
                    }
                }
                else
                {
                    lastText = "";
                }
                base.OnTextChanged(e);
            }
        }

  • 相关阅读:
    存储类&作用域&生命周期&链接属性
    关于mysql数据库的备份和还原
    Centos 7下mysql的安装与配置
    基于Apache+php+mysql的许愿墙网站的搭建
    关于php留言本网站的搭建
    linux下面桌面的安装
    时间同步ntp服务的安装与配置
    通过挂载系统光盘搭建本地yum仓库的方法
    linux系统root用户忘记密码的重置方法
    linux系统的初化始配置
  • 原文地址:https://www.cnblogs.com/changbaishan/p/11208591.html
Copyright © 2011-2022 走看看