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;
                }
            }
        }
    }
    自动驱动未来
  • 相关阅读:
    使用浏览器的 Local Storage 真的安全吗?
    传统到敏捷的转型中,谁更适合做Scrum Master?
    HBM2E Flashbolt--提升人工智能的算力
    C语言 for 循环
    C语言自加自减运算符(++i / i++)
    C语言逗号表达式
    C语言逻辑运算符
    C语言三目运算符
    C语言条件判断 if / else
    C语言 printf 函数
  • 原文地址:https://www.cnblogs.com/rb-huang/p/13791521.html
Copyright © 2011-2022 走看看