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);
            }
        }

  • 相关阅读:
    js的包装对象
    js-原型
    js面向对象初识
    css3-3d
    用css制作三角形
    清浮动
    IE67下浮动元素margin-bottom值失效问题
    css圆角
    Use Memory Layout from Target Dialog Scatter File
    Qt QSting
  • 原文地址:https://www.cnblogs.com/changbaishan/p/11208591.html
Copyright © 2011-2022 走看看