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;
                }
            }
        }
    }
    自动驱动未来
  • 相关阅读:
    汉语-词语:注重
    汉语-词语:解释
    汉语-词语:接受
    汉语-词语:专注
    汉语-词语:构想
    生物-植物-果树:枣树
    汉语-词语:维度
    汉语-词语:真传
    XML基础知识学习
    Java Swing界面编程(25)---事件处理:鼠标事件及监听处理
  • 原文地址:https://www.cnblogs.com/rb-huang/p/13791521.html
Copyright © 2011-2022 走看看