zoukankan      html  css  js  c++  java
  • C#实现某一属性值变化时触发事件 Form1_changeEvent是对应的事件

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    namespace WindowsFormsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            int i = 0;
            private void Form1_Load(object sender, EventArgs e)
            {
                changeEvent += Form1_changeEvent;
            }
            void Form1_changeEvent(string value)
            {
                this.richTextBox1.Invoke(new Action(() => { this.richTextBox1.AppendText("当前lable的值为" + value+" "); }));
            }
            private void button1_Click(object sender, EventArgs e)
            {
                Temp = i + "";
                label1.Text = Temp;
                i++;
            }
            public delegate void ChangeDelegate(string value);
            public event ChangeDelegate changeEvent;
            public string _temp;
            public string Temp
            {
                get { return _temp; }
                set
                {
                    if (_temp != value)
                    {
                        changeEvent(value);
                    }
                    _temp = value;
                }
            }
        }
    }
    自动驱动未来
  • 相关阅读:
    js加载完所有的图片,适合电子相册哦~~~~
    获取路径参数的方法
    JS 对数组的常用处理
    JS date常用代码积累
    js框架设计1.4类型判断
    js框架设计1.3数组化
    js框架设计1.2对象扩展笔记
    js框架设计1.1命名空间笔记
    java 跨域
    ACM-ICPC 2018 徐州赛区网络预赛 I Characters with Hash(模拟)
  • 原文地址:https://www.cnblogs.com/rb-huang/p/13791521.html
Copyright © 2011-2022 走看看