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;
                }
            }
        }
    }
    自动驱动未来
  • 相关阅读:
    Ruby单例方法和实例方法
    Silverlight本地化和全球化
    多线程 or 多进程 (转强力推荐)
    循环pthread_create导致虚拟内存上涨
    int在linux上的保存情况
    查看数据流的流程
    查看linux系统版本,内核,CPU,MEM,位数的相关命令(转)
    0/1背包问题
    linux下计算程序运行时间
    夸平台夸字符编码问题
  • 原文地址:https://www.cnblogs.com/rb-huang/p/13791521.html
Copyright © 2011-2022 走看看