Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do Settings work with the ToolStripManager?

Settings are another feature handled in ToolStripManager. This uses the settings engine to automatically persist and restore the entire ToolStrip tree. This allows you to enable drag to dock scenarios in the ToolStripPanel and AllowItemReorder without having to manage restoring or saving that state. Add the following code to a form with ToolStrips on it and experiment. Make sure you've named your ToolStrips, they are in ToolStripPanels so they can be moved, and AllowItemReorder is set to true to enable ALT+drag item shuffling.

private void Form1_Load(object sender, EventArgs e)
{
// load and apply settings last saved
ToolStripManager.LoadSettings(this);
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
// Save out current state of ToolStrips
ToolStripManager.SaveSettings(this);
}