主窗体累积从窗体的点击次数

来源:互联网 发布:网络维护工具 编辑:程序博客网 时间:2024/05/18 18:22

//主窗体代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace showMutiForm_net2_1
{
    public partial class AddCounts : Form
    {
        private otherForms ofrs;

        public AddCounts()
        {
            InitializeComponent();
           
        }

        private void btnOpenForms_Click(object sender, EventArgs e)
        {
            ofrs = new otherForms( this );
            ofrs.Show();
        }

        public void click_count( int count )
        {
            lblCounts.Text = ""+ count;
        }
    }
}

 

//从窗体代码

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace showMutiForm_net2_1
{
    public partial class otherForms : Form
    {
        static int count =0;
        private AddCounts acs1;
        public otherForms( AddCounts acs )
        {
            InitializeComponent();
            acs1 = acs;
        }

        private void btnAddCount_Click(object sender, EventArgs e)
        {
            count += 1;
            acs1.click_count(count);
        }
    }
}

原创粉丝点击