ToolStrip Disappears
-
12 iunie 2006 14:44
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
Toate mesajele
-
12 iunie 2006 15:08
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
-
27 iulie 2006 20:41
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
-
1 mai 2007 20:23
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
-
31 mai 2007 11:49I'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?
-
31 mai 2007 16:42
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);
}
}
} -
31 mai 2007 17:21Ah 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 -
7 iunie 2007 12:17
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
) -
15 aprilie 2008 02:26Visual Studio 2008 still has this problem. It's a bug in the winform designer and has been around for years. It's so irritating and a huge issue for us as we can't release without constantly checking to see that these are still visible. We're starting to lose confidence in the designer, especially after all this time.
-
22 aprilie 2008 22:24
Hi All,
Because I had to many Toolstrips into tabs controls and it became a nightmare to find the hiden ones, I did a very small add-in to put the visible property to true again.
Here is the add-in:
http://membre.oricom.ca/frabla/controls/FrablaToolstripVisibilityFix/SetupFrablaToolstripVisibilityFix.msi
I hope that it will be usefull for anyone who have the same problem! Cheer!
Frank -
22 aprilie 2008 22:25
Ho! I forgot to say that add-in is made for VS2005, I don't know if it works with 2008! -
20 aprilie 2009 07:10Yeah, this does have to do with the visibility settings. I found the problem to one similiar issue as well that's been around for 4 years. I already posted the work around solution at the link below.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=119591&wa=wsignin1.0 -
21 aprilie 2010 17:41If this problem still exists in Visual Studio 2010, I will become a clocktower sniper. This is a horrifically annoying bug. It does it at random too. It's not consistent, but 1 out of 4 or 5 times, it comes back as visible = false.
-
21 aprilie 2010 17:42this doesn't work either. Probably doesn't help that I can't read French!!!
-
21 iulie 2010 20:44
Can anyone confirm is this has been fixed for Visual Studio 2010?
I've manually added the *.Visible = true for each bindngnavigator object in the *Desinger.cs file , do Ctrl+S and "Clean Solution" and Rebuild.
Whenver I add a new bindingNavigator object, i make sure to manually set the .Visible property, even if it's defaulted to true in the Propeties Window.
So far, it appears to work for me.
Microsoft should be ashamed as they are not follwing basic Agile Development principles as this was a VS 2005 bug...tsk, tsk, tsk.
-
20 august 2010 21:00
I can reproduce this bug everytime on my system. Double click on any item in the navigator, including the navigator itself (actually, I haven't tested this for EVERY item, but so far everyone I've tried does the same). When the text editor opens up to the corresponding event (such as BindingNavigatorMoveNextItem_Click), delete that event. When you go back to the form, the visible property will be changed to false.
So, what might help some people is to avoid clicking on certain controls in the navigator as a quick way to open up the editor to the control you want with the intent of then changing the event from the event drop down menu. That's what I had been doing, followed by deleting the first event that came up which I didn't want. That's exactly when the navigator visible property would get set to false.
Tim
-
23 septembrie 2010 22:56
I have only just stumbled across this bug. I am using Visual Studio 2010 Ultimate.Can anyone confirm is this has been fixed for Visual Studio 2010?
-
26 octombrie 2010 15:33I'm using VS2010, and I STILL have this issue. It just happened to me twice in a row, and I ended up releasing a version with a hidden toolbar because it happened right before publish. I never change the visible property, but they often disappear on their own. So annoying.
-
1 iulie 2011 20:15
This issue raises my blood pressure. It's such an obnoxious bug when doing any kind of development with WinForms, tabs and toolstrips. Everytime the form is refreshed in the designer it sets the visible property for the toolstrips to false.
-
3 septembrie 2011 08:53I'm using VS2010 SP1 and still having issues :(
-
25 ianuarie 2012 02:25I've been working on a project for 8months in VS2008, and just today flipped all my images from 'import' to 'project resource file' (embedded).. and whalla! This glich surfaced for the first time with a vengance! Since I haven't had this error until now, I suspect it has something to do with this, but dunno.
-
7 martie 2012 00:13
Yep - here it is, 2012, and the bug is still there in Visual Studio 2010 Professional with SP1.
My application has 5 bindingNavigators (and will have a whole lot more soon). And from time to time, depending on what I'm doing, one or two of them has the Visibility property set False. It seems to happen if I work on a tabPage or tabControl unrelated to the going-invisible bindingNavigator.
Maybe they'll fix it in a service pack, but more likely it will perpetuate into VS 2012? 2014?
-Dave
-
7 martie 2012 17:50
Yep - here it is, 2012, and the bug is still there in Visual Studio 2010 Professional with SP1.
My application has 5 bindingNavigators (and will have a whole lot more soon). And from time to time, depending on what I'm doing, one or two of them has the Visibility property set False. It seems to happen if I work on a tabPage or tabControl unrelated to the going-invisible bindingNavigator.
Maybe they'll fix it in a service pack, but more likely it will perpetuate into VS 2012? 2014?
-Dave
I don't want to just be negative because it doesn't accomplish much, but the realist in me says that it's been 6 years and the bug has propagated to the current version of Visual Studio even with it's underpinnings changing drastically. I'm not going to hold my breath that it will be fixed in the next version of VS (since there is a workaround, it's more of a irritation than a road block).
I've seen multiple issues on connect.microsoft.com regarding this issue. MS responses range from "we're looking into it" (6 years ago) to it was fixed (it was not). All I can suggest it posting the issue to connect with steps to reproduce (or if there is an issue still open for the same problem, vote it up and provice your feedback). That's the best way to get it in MS's world. WinForms is probably taking a backseat (as a mature product) to WPF and the technologies that will be driving Windows 8 appliations. It should be noted, that's just my assumption until someone in the know states otherwise.
-
8 martie 2012 00:18
I don't want to be negative either - here's what doesn't work, and here's my workaround:
What doesn't work:
Any fixes that including modifications to form.Designer.CS file, inside the InitializeComponent method, will not work. Indeed, even if you add code to InitializeComponent such as
this.myBindingNavigator.Visible = true;
That will not work. I even tried to move and adjust the "Windows Form Designer generated code" #region and #endregion tags.
Even if you add code to form.Designer.CS, eventually Visual Studio removes it.
For example, if you add the code "this.myBindingNavigator.Visible = true;" to the form.Designer.CS. Save, Clean build, Save, close solution, open solution, etc. ... it may seem to work.
BUT - as soon as you move ANY tab page controls (or any controls) which forces Visual Studio to auto-edit the designer.cs file, Visual Studio removes all your code changes. BAM - all your changes are gone!
The easy work around is:
Add the code (or similar code)this.myBindingNavigator.Visible = true;
into a new method in the form.cs file and call it on initialization from form_Load. Then for sure, your navigators are visible at run time.
To see them during Design-Time - just select the one you want with the mouse, from the gray area below your form.
-Dave -
14 mai 2012 04:26
namespace
namespace Example
{
publicpartialclass ExampleForm: Form
{
publicForm1()
{
InitializeComponent();
toolstripmenu.Show();
}
-
9 august 2012 14:37
I have battled this problem for a few days now, where the toolstrip disappears. The problem started when I added an image to one of the buttons. Previously, the toolstrip buttons where without images.
I use Visual Studio 2010 .Net 4.0, so a much newer problem and it seems that Microsoft still has not fixed this issue.
The toolstrip is on one of the tabs in a tab control, like others here.
I did NOT, and I repeat NOT, set the visible property to false. Why? Still, the visible property became set to false. Setting the property to true resolved the issue.
Does adding an image to a button, if the toolstrip is on a tab control cause the visible property to get set to false?
Also, what fool designed a design and runtime behavior where if the visible property is false, the control disappeas unless it is selected and nowhere to be seen at runtime.
This behavior is obviously a bug and Microsoft in over six years has not felt the need to fix it. I wasted oodles of time on this issue before deciding to do a Google search. I chose the proper keywords "Toolstrip disappears", first hit.
If any person with clout at Microsoft is reading these posts. PLEASE FIX THIS BUG! I did not do anything and ran into this bug. I suspect that the problem is as old as .Net an was there previously, just no one complained about it before June 2006. August 2012 and still. Pathetic.
-
28 august 2012 01:43
I have battled this problem for a few days now, where the toolstrip disappears. The problem started when I added an image to one of the buttons. Previously, the toolstrip buttons where without images.
I use Visual Studio 2010 .Net 4.0, so a much newer problem and it seems that Microsoft still has not fixed this issue.
The toolstrip is on one of the tabs in a tab control, like others here.
I did NOT, and I repeat NOT, set the visible property to false. Why? Still, the visible property became set to false. Setting the property to true resolved the issue.
Does adding an image to a button, if the toolstrip is on a tab control cause the visible property to get set to false?
Also, what fool designed a design and runtime behavior where if the visible property is false, the control disappeas unless it is selected and nowhere to be seen at runtime.
This behavior is obviously a bug and Microsoft in over six years has not felt the need to fix it. I wasted oodles of time on this issue before deciding to do a Google search. I chose the proper keywords "Toolstrip disappears", first hit.
If any person with clout at Microsoft is reading these posts. PLEASE FIX THIS BUG! I did not do anything and ran into this bug. I suspect that the problem is as old as .Net an was there previously, just no one complained about it before June 2006. August 2012 and still. Pathetic.
First, another thread where they talk about likely the same bug. Second, a connect ticket that everyone who has this issue should up vote to see if this can get addressed. I have the same sentiment about this bug (I can deal with it, but it's one of those really irritating time wasters that pops up over and over).
-
28 august 2012 16:48
Wow! Over eleven thousand views and 26 replies. "pbell" - don't fret over this not working. We won't get it to work, but someday MS will fix it. For now, I just click on the control's icon in the "tools region" below the form. Or I can select it from the dropdown in the properties window.
-Dave
-
5 decembrie 2012 05:23
Like so many others, I too have experienced this problem.
My latest effort, which seems to be working, it to place the ToolStrip on a panel. Set the Dock property of the ToolStrip to "Full", then dock the panel to the "Top" of the tab. You'll need to size the panel manually, but it seems to avoid the disappearing ToolBar issue.
-
7 februarie 2013 12:37
Same problem here.
Environment: Visual Stuido 2010, .NET 4 framework, Windows Forms Application, TabControl, TabPages, ToolStrip
Problem: The ToolStrip or BindingNavigator property "Visible" is sometimes set to false by the Designer.Steps to reproduce this behaviour with ToolStrip:
- Create new Windows Forms Application project.
- Add a TabControl, set dock to fill in properties.
- Add a ToolStrip on each of the two TabPage(s), notice that the "Visible" property is true for both ToolStrip(s).
- Select both ToolStrip(s) in the Panel below (either drag mouse to select or click while holding the ctrl key).
- Click on empty space in the panel. Notice that the "Visible" property value of the ToolStrip that got selected last is now False.
The same is happending if you use a BindingNavigator which internally is derived from ToolStrip. The problem seems to be within
System.Windows.Forms.ToolStripDesigner, which is the designer used when visually editing a ToolStrip or a BindingNavigator.
(BindingNavigator uses the System.Windows.Forms.BindingNavigatorDesigner which itself is derived from ToolStripDesigner)After starting to write a custom Designer for a custom ToolStrip I soon realized that the programmers at Microsoft didn't do this in just one day.
Anyway here is what I came up with the next day:
- Changed existing project to .NET 4 framework (not the .NET 4 client profile since we need the System.Design assembly)
- Added a control library project (.NET 4 framework) to my existing solution, and called it "CustomControls"
- Added a new class to the control library and called it "ToolStripEx"
- In the existing project I added a project reference to the library project.
- In the library project I added a reference to System.Design
- I derived ToolStripEx from ToolStrip
- I replaced all System.Windows.Forms.ToolStrip occurances in Form1.Designer.vb with CustomControls.ToolStripEx
- After some time I finally came up with this code:
VB.NET ToolStripEx
Imports System Imports System.Collections Imports System.Windows.Forms Imports System.Windows.Forms.Design Imports System.Reflection Imports System.ComponentModel.Design Public Class ToolStripEx : Inherits ToolStrip Private Const WM_GETTEXT As Integer = &HD Private components As System.ComponentModel.IContainer Public Sub New() MyBase.new() End Sub Public Sub New(ByVal container As System.ComponentModel.IContainer) MyClass.New() If (container IsNot Nothing) Then container.Add(Me) End If End Sub Private Sub InitializeComponent() components = New System.ComponentModel.Container() End Sub Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) MyBase.WndProc(m) If Me.DesignMode Then If m.Msg = WM_GETTEXT Then SetVisibleEx() End If End If End Sub Private Sub SetVisibleEx() If Me.DesignMode Then Try If Me.Site IsNot Nothing Then If Me.Site.Component IsNot Nothing Then If TypeOf Me.Site.Container Is IDesignerHost Then Dim ihost As IDesignerHost = CType(Me.Site.Container, IDesignerHost) Dim idesigner As IDesigner = ihost.GetDesigner(Me) If idesigner IsNot Nothing Then If idesigner.GetType.Name = "ToolStripDesigner" Then Dim ctrlDesigner As ControlDesigner = CType(idesigner, ControlDesigner) Dim prop As PropertyInfo = ctrlDesigner.GetType.GetProperty("Visible", BindingFlags.NonPublic Or BindingFlags.Instance) If prop IsNot Nothing Then Dim visibleValue As Boolean = CBool(prop.GetValue(ctrlDesigner, Nothing)) If visibleValue <> mVisibleEx Then visibleValue = mVisibleEx ctrlDesigner.Control.Visible = visibleValue prop.SetValue(ctrlDesigner, visibleValue, Nothing) End If End If End If End If End If End If End If Catch ex As Exception End Try Else Me.Visible = mVisibleEx End If End Sub Private mVisibleEx As Boolean = True Public Property VisibleEx As Boolean Get Return mVisibleEx End Get Set(value As Boolean) If mVisibleEx <> value Then mVisibleEx = value SetVisibleEx() End If End Set End Property End ClassC# BindingNavigatorEx
using System; using System.Collections; using System.Windows.Forms; using System.Windows.Forms.Design; using System.Reflection; using System.ComponentModel.Design; namespace CustomControls { public class BindingNavigatorEx : BindingNavigator { private const int WM_GETTEXT = 0xD; private System.ComponentModel.IContainer components = null; public BindingNavigatorEx(System.ComponentModel.IContainer container) : base(container) { InitializeComponent(); } private void InitializeComponent() { components = new System.ComponentModel.Container(); } protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } protected override void WndProc(ref Message m) { base.WndProc(ref m); if (this.DesignMode) { if (m.Msg == WM_GETTEXT) { SetVisibleEx(); } } } private void SetVisibleEx() { if (this.DesignMode) { try { if (this.Site != null) { if (this.Site.Component != null) { if (this.Site.Container is IDesignerHost) { IDesignerHost ihost = (IDesignerHost)this.Site.Container; IDesigner idesigner = ihost.GetDesigner(this); if (idesigner != null) { if (idesigner.GetType().Name == "BindingNavigatorDesigner") { ControlDesigner ctrlDesigner = (ControlDesigner)idesigner; PropertyInfo propInfo = ctrlDesigner.GetType().GetProperty("Visible", BindingFlags.NonPublic | BindingFlags.Instance); if (propInfo != null) { Boolean visibleValue = (Boolean)propInfo.GetValue(ctrlDesigner, null); if (visibleValue != mVisibleEx) { visibleValue = mVisibleEx; ctrlDesigner.Control.Visible = visibleValue; propInfo.SetValue(ctrlDesigner, visibleValue, null); } } } } } } } } catch (Exception ex) { } } else { this.Visible=mVisibleEx; } } private Boolean mVisibleEx=true; public Boolean VisibleEx { get { return mVisibleEx; } set { if (mVisibleEx != value) { mVisibleEx = value; SetVisibleEx(); } } } } }Now I can set the visibility of the ToolStrip thru the property "VisibleEx" and the "Visible" property is working in the test scenario.
I'm assuming that the designer reads the Text property everytime the Visible property is set.
I really hope that the designer sends a WM_GETTEXT message to the custom ToolStrip everytime the bug is hit, if so then the problem is solved for me.
If not then removing the WndProc condition WM_GETTEXT or finding an event is the last chance to get it working like this.Until now it is working.
Regards
A.J.
Don't panic! Debug it.