它「聽起來像」你想有孩子SDI形式跟父基本形式,在這種情況下,嘗試使用事件:
在孩子SDI形式:
public partial class ChildForm : Form
{
public delegate void DisableBaseHandler(object sender, EventArgs e);
public event DisableBaseHandler DisableBase;
public ChildForm()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
OnDisableBase();
}
private void OnDisableBase()
{
if (DisableBase != null)
DisableBase(this, new EventArgs());
}
}
,並在父基本形式:
public partial class BaseForm : Form
{
private ChildForm _OtherForm;
public BaseForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (_OtherForm == null || _OtherForm.IsDisposed)
{
_OtherForm = new ChildForm();
_OtherForm.DisableBase += new ChildForm.DisableBaseHandler(DisableMe);
}
_OtherForm.Show();
}
private void DisableMe(object sender, EventArgs e)
{
//Disable Base Controls...
button1.Enabled = false;
}
}