110,533
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
userControl1.comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged;
}
private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (userControl31.comboBox1.SelectedItem)
{
case "1":
userControl41.TextOfTextBox = "11111";
break;
case "2":
userControl41.TextOfTextBox = "22222";
break;
case "3":
userControl41.TextOfTextBox = "33333";
break;
case "4":
userControl41.TextOfTextBox = "44444";
break;
}
}
public System.Windows.Forms.ComboBox comboBox1;
public string LabelText
{
get { return this.label1.Text; }
set { this.label1.Text = value; }
}
public UserControl3()
{
InitializeComponent();
}
public event Action<string> SubmitEvent;
private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBox1.SelectedItem)
{
case "1":
SubmitEvent("1111");
break;
case "2":
SubmitEvent("2222");
break;
case "3":
SubmitEvent("3333");
break;
case "4":
SubmitEvent("4444");
break;
}
}
public Form2()
{
InitializeComponent();
userControl31.SubmitEvent += new Action<string>(labelTextEvent);
}
void labelTextEvent(string obj)
{
userControl41.LabelText = obj;
}
public UserControl4()
{
InitializeComponent();
}
public string LabelText
{
get { return this.label1.Text; }
set { this.label1.Text = value; }
}
[/quote]
收到 我先结贴
等会儿再研究 委托的办法 我搞了很久就是有些问题 真是太感谢你了 努力向你学习 public UserControl3()
{
InitializeComponent();
}
public event Action<string> SubmitEvent;
private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBox1.SelectedItem)
{
case "1":
SubmitEvent("1111");
break;
case "2":
SubmitEvent("2222");
break;
case "3":
SubmitEvent("3333");
break;
case "4":
SubmitEvent("4444");
break;
}
}
public Form2()
{
InitializeComponent();
userControl31.SubmitEvent += new Action<string>(labelTextEvent);
}
void labelTextEvent(string obj)
{
userControl41.LabelText = obj;
}
public UserControl4()
{
InitializeComponent();
}
public string LabelText
{
get { return this.label1.Text; }
set { this.label1.Text = value; }
}