//主窗体代码
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);
}
}
}