English 中文(简体)
装满双双双双双双管齐下时的分辨率
原标题:Strange behavior when loading mdi winform c# .net

I ́m在MDI WinForms申请中获得了一种奇怪的行为。 当某一具体形式与任何其他形式一起开放时,这种具体形式就锁定了。 在某种程度上,它把这两种形式的控制Box混为一谈。

“entergraph

由于表格已停止反应,无法接近并停止了油漆:

“entergraph

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弃下一步工作的想法。

问题回答
newForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;

The above line is called for all your controls, which results in the control boxes being grouped together.

As for that form freezing up, you need to post the code of the child form that causes the form freeze. Then I can assist you further.





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签