【发布时间】:2017-01-19 08:33:00
【问题描述】:
我需要一种将用户控件传递给用户控件的方法。
我正在使用 Windows 窗体。
例如。假设我在用户控件 1 中有一个单选按钮,我希望用户控件 2 调用并查看用户控件 1 上是否选中了该单选按钮。我将如何引用它?
还有一些示例代码:
这是 UserControl1
public void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
这是 UserControl2
private void button4_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
//do something
else
//do something
}
【问题讨论】:
-
userControl1 与 userControl2 的关系如何?是儿童控制吗?还是在表单上独立使用两个控件?还是 WebForms 还是 WInForms?