111,093
社区成员




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 WinFormExample
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
OtherForm form = new OtherForm();
form.recorder += this.ShowCount;
form.Show();
Form1 f1 = new Form1();
form.recorder += f1.showCount;
f1.Show();
}
private void ShowCount(string count)
{
this.label1.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 WinFormExample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void showCount(string showCounter)
{
this.label1.Text = "你己点击窗体" + showCounter + "次";
}
}
}
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 WinFormExample
{
public partial class OtherForm : Form
{
public delegate void ShowInfo(string info);
public ShowInfo recorder;
private int counter = 0;
public OtherForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
counter++;
if (recorder != null)
recorder(counter.ToString());
}
}
}
private void button1_Click(object sender, System.EventArgs e)
{
MyClass mc = new MyClass();
mc.Username = userid.Text;
}
namespace A
{
...
public class Login_Form : System.Windows.Forms.Form
{
public class MyClass
{
public string username;
public string Username
{
get
{
return username;
}
set
{
username = value;
}
}
}
}
...
}
namespace 学生宿舍管理系统
{
public class Pwdedit_Form : System.Windows.Forms.Form
{
...
private void username_Click(object sender, System.EventArgs e)
{
username1.Text = mc.Username;
}
...
}
}
public static class MyClass
{
public static string username;
public static string Username
{
get
{
return username;
}
set
{
username = value;
}
}
}