This article mainly introduces the production of C # ToolStrip floating toolbar, can dock up/down/left/right, the code below
About the production of floating bar In fact, the code given by Atzie is quite detailed: I mainly give a rewrite of the ToolStrip code snippet, added three ToolStripPanel code as follows: public partial class Mytoolstrip:too Lstrip { public Mytoolstrip () { InitializeComponent (); this. EndDrag + = new EventHandler (Mytoolstrip_enddrag); this. SizeChanged + = new EventHandler (mytoolstrip_sizechanged); } #region floating status public to Olstripfloatwindow Floatwindow {get; set;} private bool isfloating &NBS P { get { &N Bsp return (Floatwindow!= null); &NBSP { } ToolStripPanel Toptoolstrippanel {get; set;} & nbsp Public ToolStripPanel Bottomtoolstrippanel {get; set;} public ToolStrip Panel Lefttoolstrippanel {get; set;} public ToolStripPanel Righttoolstrippanel {get; set;} #endregion #region float implementation private void Floatwindow_locationchanged (object sender, EventArgs e) { & nbsp //When FLOATWINDWS position is moved to ToolStripPanel, this is placed on ToolStripPanel &N Bsp if (this. Floatwindow = null) { R Eturn; if (floatwindow.hascreateD { //main form position &NBS P Point frmloc = this. TopToolStripPanel.Parent.Location; //floating tool strip location Point toolbarloc = floatwindow.location; if (toolbarloc.y-frmloc.y <= 0)///Top Strippanel   ; { T His. FloatWindow.Controls.Remove (this); this. Toptoolstrippanel.suspendlayout (); this. TOPTOOLSTRIPPANEL.CONTROLS.ADD (this); this. Location = this. ToptoolstrippaneL.pointtoclient (Toolbarloc); this. Toptoolstrippanel.resumelayout (); this. Floatwindow.dispose (); this. Floatwindow = null; return; if (tool barloc.x-frmloc.x <= 0)//to left Strippanel { &NBS P this. FloatWindow.Controls.Remove (this); this. Lefttoolstrippanel.suspendlayout (); this. LEFTTOOLSTRIPPANEL.CONTROLS.ADD (this); &NBsp this. Location = this. Lefttoolstrippanel.pointtoclient (Toolbarloc); this. Lefttoolstrippanel.resumelayout (); this. Floatwindow.dispose (); this. Floatwindow = null; return; if (tool barloc.x + floatwindow.width >= this. TopToolStripPanel.Parent.Width)//to the right Strippanel { & nbsp this. FloatWindow.Controls.Remove (this); this. Righttoolstrippanel.suspendlayout (); this. RIGHTTOOLSTRIPPANEL.CONTROLS.ADD (this); this. Location = this. Righttoolstrippanel.pointtoclient (Toolbarloc); this. Righttoolstrippanel.resumelayout (); this. Floatwindow.dispose (); this. Floatwindow = null; return; if (tool Barloc.y + floatwindow.height >= this. TopToolStripPanel.Parent.Height)//At bottom Strippanel { this. FloatWindow.Controls.Remove (this); this. Bottomtoolstrippanel.suspendlayout (); this. BOTTOMTOOLSTRIPPANEL.CONTROLS.ADD (this); this. Location = this. Bottomtoolstrippanel.pointtoclient (Toolbarloc); this. Bottomtoolstrippanel.resumelayout (); this. Floatwindow.dispose (); this. Floatwindow = null; return; } } private void Mytoolstrip_enddrag (object sender, EventArgs e) &N Bsp { Point screenpt = cursor.position Po int clientpt = this. TopToolStripPanel.Parent.PointToClient (SCREENPT); //floating area Rectangle Floatarea = NE W Rectangle ( //) I have this icon resize to 32*32 this. Toptoolstrippanel.parent.width-2 * 32, this. Toptoolstrippanel.parent.height-2 * 32); if (Floatarea.contains (CLIENTPT))//Judgment shift time &NB Sp { Toolstripfloatwindow fw = new Toolstripfloatwindow (); &nb Sp FW. Controls.Add (this); this. left = 0; &NBSP; this. top = 0; this. Floatwindow = FW; floatwindow.locationchanged + = new EventHandler (floatwindow_locat ionchanged); FW. SetBounds (Screenpt.x, Screenpt.y, this.) Clientsize.width, this. Clientsize.height + 22); 22 for the form title bar height FW. Show (); &NBSP, { Private void Mytoolstrip_sizechanged (object sender, EventArgs e) { if (this.isfloating) { this. Floatwindow.width = this. Clientsize.width; } }   #endregion }