C# WinForm programming, simultaneous activation of multiple window, click a butt

C# WinForm programming: running, simultaneous activation of multiple form, a form for every boot, a button button to dynamically generate the form corresponding? Click on the button button, how will the corresponding forms are displayed in the most outside? After the form is closed, the button.

Key: the simultaneous activation of multiple window, click a button button, turn a form the button corresponding to the display in the most outside, rather than by clicking the form!!!

Started by Andrew at February 09, 2016 - 2:47 PM

Open the form is created when a labeled button, the form is closed, the corresponding remove labeled button.
Click on the button, also let a form is displayed on it

Posted by Jean at February 16, 2016 - 3:28 PM

Do you want a similar browser that function.

Posted by Jean at February 26, 2016 - 3:36 PM

class WindowNotifier
{
public static readonly WindowNotifier instance = new WindowNotifier();
public void Open() { OnOpen(this, new EventArgs()); }
public void Close() { OnClose(this, new EventArgs()); }
public event EventHandler OnOpen;
public event EventHandler OnClose;
}

Write a form class:
class FormBase
{
public FormBase() {
this.Load += (a, b) => WindowNotifier.instance.Open();
this.UnLoad += (a, b) => WindowNotifier.instance.Close();
}
}

Other forms inherit from it
class Form1 : FormBase
{
void Form_Load()
{
WindowNotifier.instance.OnOpen += RefreashButtons();
WindowNotifier.instance.OnClose += RefreashButtons();
}
void RefreashButtons(sender, e)
{
foreach (var item in this.Controls.OfType<Button>().ToList()) this.Controls.Remove(item);
foreach (Form item in Application.OpenedForms)
{
Button btn = new Button();
btn.Tag = item;
btn.Text = item.Text;
btn.Location = ...
btn.Size = ...
btn.Click += (a, b) => ((a as Button).Tag as Form).Close();
this.Controls.Add(btn);
}
}
}

Posted by Christina at March 09, 2016 - 3:52 PM

Well, mainly is the simultaneous activation of multiple forms, the corresponding dynamic generation of multiple button button (a form corresponding to a button button), click a button button, turn a form the button corresponding to the display in the most outside, rather than by clicking the form, is how to do, I was a beginner, no idea.

Posted by Andrew at March 22, 2016 - 3:56 PM

TabControl cannot meet the requirements?

Posted by Philip at March 29, 2016 - 4:12 PM

I've been using the TabControl, can not meet.,

Posted by Andrew at April 03, 2016 - 4:57 PM

TabControl can be.

Posted by Drew at April 12, 2016 - 5:40 PM

Use the MagicDocking effect will be better

Posted by Drew at November 20, 2016 - 9:56 AM

This is done with toolStrip, you make changes, with button, button dynamically created in the flowLayoutPanel without manual control position,

And dev xtraTabbedMdiManager the controls without writing code can meet you requirements


    private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            for (int i = 0; i <this.MdiChildren.Length; i++)
            {
                if (this.MdiChildren[i] == e.ClickedItem.Tag)
                {
                    this.MdiChildren[i].Activate();
                }
            }
        }



       void BaseForm_ChlidFormClosedEvent(Form form)
        {

                for (int i = 0; i <toolStrip1.Items.Count; i++)
                {
                    if (toolStrip1.Items[i].Tag == form)
                    {
                        if (StrName.Count != 0)
                        {
                            for (int j = 0; j <StrName.Count; j++)
                            {
                                if (StrName[j] == toolStrip1.Items[i].Tag)
                                    StrName.Remove(StrName[j]);
                            }
                        }
                        this.toolStrip1.Items.Remove(toolStrip1.Items[i]);
                    }
                }

        }

Posted by Jean at November 26, 2016 - 10:52 AM

Well, I try, don't understand to ask you ah.

Posted by Andrew at December 05, 2016 - 11:33 AM

Xi Feng predecessors, Hello, I do not know ah, can leave behind the contact method, I QQ: 2446872525

Posted by Andrew at December 19, 2016 - 11:43 AM

Do not need to generate button, in a.Net application, every open a form,.Net will send the form to a form collection (Appliction.OpenForms), in order to make the form appears at the top, just call the Appliction.OpenForms[form (Name].Activate). You should do is a window manager, following the simple idea: to traverse the Application.OpenForms, the title and Name of each form is stored in listView, the user selected point after activation, as information call Activate () can be selected by user. Not only has the activation function, in the MdiParent.Layout () method also provides a laminate, horizontally, vertically arranged and form function (can only be used in MDI).

Posted by Peggy at December 25, 2016 - 12:41 PM

This method is more convenient

Posted by Manda at December 26, 2016 - 1:12 PM


Purchasing management of UIL.Frm_CaiGouGuanLi myfrm_CaiGouGuanLi = new UIL.Frm_CaiGouGuanLi procurement management(ref MyPanel);
 panel2.Controls.Clear();
 myfrm_CaiGouGuanLi.TopLevel = false;
 myfrm_CaiGouGuanLi.Parent = panel2;
 myfrm_CaiGouGuanLi.Show();

I use panel as the parent container,

Posted by Andrew at January 03, 2017 - 1:40 PM

Purchasing management of UIL.Frm_CaiGouGuanLi myfrm_CaiGouGuanLi = new UIL.Frm_CaiGouGuanLi procurement management(ref MyPanel);
            panel2.Controls.Clear();
            myfrm_CaiGouGuanLi.TopLevel = false;
            myfrm_CaiGouGuanLi.Parent = panel2;
            myfrm_CaiGouGuanLi.Show();

Posted by Andrew at January 04, 2017 - 2:28 PM

To achieve the functions such as map

Posted by Andrew at January 12, 2017 - 1:50 PM