Tag Archives: Toolstrip

Getting a value of a ToolStripTextBox on a lost focus

Using the Leave event does not work unless you press Tab key (which presumably takes the focus of the entire ToolStrip).

To detect the lost focus of the ToolStripTextBox use the LostFocus event. It is not in the designer and needs to be added manually, typically from the forms constructor.

public Form1()
{
   toolStripTextBox1.LostFcus += new EventHandler(toolStripTextBox1_LostFocus);
}

void toolStripTextBox1_LostFocus(object sender, EventArgs e)
{
   //Access the text property
   string value = toolStripTextBox1.Text;
}
Lastest update in May 2011, inital post in May 2011

Disable a toolbar or ToolStripPanel

Individual toolbars / toolstrips can be disabled by using the enabled property.

When in a ToolStrip in inside a ToolStripContainer the entire panel (and the hosted toolstrips) can be disabled all at once.

For example
toolStripContainer1.TopToolStripPanel.Enabled = false;
toolStripContainer1.BottomToolStripPanel.Enabled = false;
toolStripContainer1.LeftToolStripPanel.Enabled = false;
toolStripContainer1.RightToolStripPanel.Enabled = false;

Note:
Do not disable the toolStripContainer1 since it will also disable the hosted panel in the center.

Lastest update in May 2011, inital post in May 2011