Jaa


Intercepting the click event on the ToolStripGrip

Unfortunately, you'll have to override OnMouseDown on the ToolStrip to get the mouse down event for the grip. The toolstrip will only fire the Mouse* events itself if an item has not intercepted the event.

Here's a super-quick sample of creating a toplevel window when a ToolStrip's grip is clicked.

  public class MyToolStrip : ToolStrip {
protected override void OnMouseDown(MouseEventArgs mea) {
if (this.GripRectangle.Contains(mea.Location)) {
Point location = PointToScreen(Point.Empty);

                Form f = new Form();
f.StartPosition = FormStartPosition.Manual;
f.Location = location;
f.Text = this.Text;

                f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
f.ClientSize = this.Size;
f.Controls.Add(this);
f.Show();

            }
else {
base.OnMouseDown(mea);
}
}
}