• 重写/覆盖基类的事件


    对于从父类继承来的事件,若子类需要在触发之后,进行 一些“特殊处理时”,建议:覆盖或重写父类的 <抽闲或虚的> 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);
            }
        }

  • 相关阅读:
    Leetcode 811. Subdomain Visit Count
    Leetcode 70. Climbing Stairs
    Leetcode 509. Fibonacci Number
    Leetcode 771. Jewels and Stones
    Leetcode 217. Contains Duplicate
    MYSQL安装第三步报错
    .net 开发WEB程序
    JDK版本问题
    打开ECLIPSE 报failed to load the jni shared library
    ANSI_NULLS SQL语句
  • 原文地址:https://www.cnblogs.com/changbaishan/p/11208591.html
Copyright © 2020-2023  润新知