Coder11

In Visual Studio 2005 during design time my toolstrip disappears when I click any part of the form. Selecting the control in the properties window combo brings the control back onto the screen.

At run time the toolbar is no where to be seen.

Can anyone help me with this

thanks



Re: Windows Forms Designer ToolStrip Disappears

Coder11

OK I sorted this out,

It appears that some joker changed the visible property to false which gives rise to the strange design time behaviour.

nice





Re: Windows Forms Designer ToolStrip Disappears

Jeff McBride

This happens to us on a regular basis when the toolstrip is inside in a tab control. Depending on which which tab is visible, what the last action you did before building/running the app, the phase of the moon on so on the toolbar on the current tab page will magically have its Visible property set to false.

It is annoying to keep having to turn it back on so I ended up writing code to recurse through the form's controls and make all of the toolstrips visible every time on the load event.

We still have to monkey around to select the toolstrip in order to make design time changes but at least we aren't accidentally releasing test builds with missing toolbars (at runtime) anymore.

Jeff





Re: Windows Forms Designer ToolStrip Disappears

Marek Zgadzaj

Jeff,

I can confirm the very similar problem. Please read my thread from here:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1545076&SiteID=1&mode=1

Marek





Re: Windows Forms Designer ToolStrip Disappears

Russell Maidment

I've been encountering this problem also, whenever I put a toolstrip on a tabpage, it keeps disappearing. For some reason it keeps getting set to Visible = False even though I am not doing that, is there a proper fix for this yet




Re: Windows Forms Designer ToolStrip Disappears

Jeff McBride

I do not know of any official fix or work-around. Here is the fix that I came up with. Just call EnsureToolbarsAreVisible(this) from your form load code.

Jeff

public void EnsureToolbarsAreVisible(Form formFix)
{
if (formFix != null)
EnsureToolbarControlsAreVisible((Control.ControlCollection)formFix.Controls);
}

public void EnsureToolbarControlsAreVisible(Control.ControlCollection ctrls)
{
if (ctrls != null)
{
try
{
foreach (Control ctrl in ctrls)
{
ToolStrip ts = ctrl as ToolStrip;
TabControl tc = ctrl as TabControl;
SplitContainer sc = ctrl as SplitContainer;

if (ts != null)
ts.Visible = true;
else if (tc != null)
{
foreach (TabPage tp in tc.TabPages)
EnsureToolbarControlsAreVisible((Control.ControlCollection)tp.Controls);
}
else if (sc != null)
{
EnsureToolbarControlsAreVisible((Control.ControlCollection)sc.Panel1.Controls);
EnsureToolbarControlsAreVisible((Control.ControlCollection)sc.Panel2.Controls);
}
else if (ctrl.Controls != null)
EnsureToolbarControlsAreVisible((Control.ControlCollection)ctrl.Controls);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}





Re: Windows Forms Designer ToolStrip Disappears

Russell Maidment

Ah nice, thanks

still annoying in design time when making changes, surprised that Microsoft haven't fixed this obvious bug yet, considering it's been here for so long




Re: Windows Forms Designer ToolStrip Disappears

Tiago Dias

If you are using a ToolStripContainer you should also checkout for the TopToolStripPanelVisible property.

Visual Studio Form designer sets this to false when you click on different ToolStrips.

If you want all your TopToolStripPanes visible consider extending the code above for a fix, if not set the appropriate TopToolStripPanelVisible property in your own code, otherwise change the Designer generated code and never use the designer again (Thank god Big Smile)