I ́m在MDI WinForms申请中获得了一种奇怪的行为。 当某一具体形式与任何其他形式一起开放时,这种具体形式就锁定了。 在某种程度上,它把这两种形式的控制Box混为一谈。
由于表格已停止反应,无法接近并停止了油漆:
The strange part is that any other combination of forms works fine. The forms gets loaded on top of each other and the application does not freeze. But i can not figure out whats different about this form compared to the others. All settings are identical. This is the code in the main MDIform that initiate new child forms, its called from a ToolStrip Button.Click event:
private void OpenForm(object sender)
{
if (sender == null) return;
ToolStripMenuItem itemSender = (ToolStripMenuItem)sender;
try
{
WinForm mapping = (WinForm)itemSender.Tag;
if (!FormList.ContainsKey(mapping.FormName))
{
Type frmType = Type.GetType(string.Format("OrderAssist.Forms.{0}", mapping.FormName));
if (frmType != null)
{
Form newForm = (Form)Activator.CreateInstance(frmType);
if (!newForm.IsDisposed)
{
newForm.Name = mapping.FormName;
newForm.Tag = itemSender;
newForm.MdiParent = this;
newForm.Show();
newForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
newForm.FormClosing += new FormClosingEventHandler(newForm_FormClosing);
FormList.Add(newForm.Name, newForm);
itemSender.Checked = true;
newForm.Activate();
}
}
else
itemSender.Enabled = false;
}
else
FormList[mapping.FormName].Activate();
}
catch (Exception e)
{
Exceptions.ProgramException(e, Settings.User.ID, "Exception occured while opening a form.");
if (itemSender != null)
itemSender.Enabled = false;
}
}
如果在开启另一种表格之前将这种数据锁定下来并点击内部的某些控制的形式,使事情变得陌生,则不会出现错误。
Im弃下一步工作的想法。