ToolStrip Position Persistence

Until recently I had always added ToolStrips to a Form and set their docking property to Top, this was acceptable until I needed to move a ToolStrip. I then began using the ToolStripContainer which allows docking and the user to drag and drop the ToolStrips around the Form.

This is well documented in MSDN however using a ToolStripContainer also allows you to make use of a not so documented class; ToolStripManager

Simply by adding a call to Save and Load settings when a form is constructed and disposed means any ToolStrips in the ToolStripContainer will start in their last used state and location.

This is shown below, each takes the Form that contains the ToolStrips as a parameter.

ToolStripManager.SaveSettings(this);
ToolStripManager.LoadSettings(this);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s