TabControl and ToolStrips:strange behaviour ?

got a form with a tabcontrol on it. On each tappage a ToolstripContainer and some Toolstrips in int.
If I see Tabpage 1 in the designer and run...then I get Toolstrips visible on Tabpage 1. Not on ex.TabPage2.
if I see Tabpage2 in the designer and run...then I get Toolstrips visible on TabPage 2. No on ex. TabPage1.
Is this meant to be or am I missing something ?
Thx
JMW
[398 byte] By [jmw] at [2007-12-16]
# 1

ToolStripContainers are specific to the form, not other container controls. Take a look at the smart tag for the ToolStripContainer. It says "Dock fill in Form". This is because it can only dock to the form. The help also says:

"Provides panels on each side of the form and a central panel that can hold one or more controls."

So this is causing your issue. If you want to do what you are attempting to do, I would add the ToolStripContainer first, dock it to the form, add the TabControl to the inner panel of the ToolStripContainer and dock it. If you want your toolstrips to change based on what tab you are on, attach to the SelectedIndexChanged event of the TabControl and hide/show ToolStrips according to what tab you are on there.

TobinTitus at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

Dock fill in form is just a helpful smart tag for a common scenario, it doesnt really define any level of support.

Regarding ToolStripContainer in a TabControl, you should probably expect this to work. Product Feedback is a good way of letting microsoft know about bugs like this.

Jessica at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
Again, this is not a bug. This is by design. Tool strips were meant to border the edges of a form. Yes, the smart tags do provide helpful common scenario support, but they also help define their functionality. For instance, drag a datagrid view onto a form and notice the smart tag specifically says "Dock fill in parent container". Meanwhile, the toolstripcontainer specifies to fill in the form because that's all it is meant to do.

Another example of what it was meant to do can be found simply by its docking behavior (outside of using the smart tags). Drag a panel onto the form, then drag a tool strip container onto the panel. Go to the properties and set the dock property to fill. It fills the form, not the panel container. This is by design and not a bug. However, you are right that product feedback can change behavior. If you and many other developers feel strongly that you should be able to dock tool strip containers to any container control, by all means, leave that feedback.

TobinTitus at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
Tobin - I think we agree that this is not a common scenario, but offhand I cant think of a reason why it shouldn't work.

Jessica
Developer, Windows Forms Team

Jessica at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5

While it may be desirable to dock or anchor a toolstrip itself to a container such as a panel (which is possible), I for the life of me can't understand why it would be desirable to be able to dock a toolstripcontainer to any random container object. This means that you would be able to pull the toolstrip off of the top of a panel and dock it to the bottom, to the form, or any other random place someone decides to place a tool strip container boundary. Not only would this be extremely complex to implement, usability of the application could be severely hampered.

Again, this is my opinion and just because I don't see why you would want to, doesn't mean it shouldn't be changed if a large group of developers think it should be changed. Obviously there are at least two people who feel it should be allowed, and the great thing about product feedback like this is that if its implemented, it doesn't hinder anyone. If its introduced as a feature and I still don't like it, I don't have to use it! ;)

TobinTitus at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6

Here's a scenario where ToolBars arent just dock'ed to the edges of the form:

In Word 11, you can press F1 to open the Word Help task pane.

You can drag the standard toolbar from the top to the right side of the form. The vertical toolbar can be dragged either to the left or the right side of the Word Help task pane.

Allowing the toolstrip container (or even individual ToolStripPanels) to be placed in different locations on the form allows more flexibility in building professional applications.

Jessica
Developer, Windows Forms Team

Jessica at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 7
How is this any different from the toolstripcontainer? The help window that is displayed is nothing more than a toolstrip (obviously not implemented with VS.NET 2005, but where they drew their ideas from). If you want to extend your application to provide the same behavior, you can simply subclass a new toolstrip type that allows for HTML content (perhaps a webbrowser control with an exposed "address" property). Notice that the help window can be dragged and docked to any edge of the Word 11 screen? This is because this too is a "toolstrip" When you drag your additional main toolbar to the right of the screen, notice that you can dock it to the far right of the help or to the far left of the help? That is same behavior you get with your current toolstripcontainer in VS.NET 2005. I can drag multiple toolstrips to the right hand side of the toolstripcontainer and they all dock over there.

If you want an example, I might have just enough gumption to write the extended toolstrip that allows HTML content. :)

TobinTitus at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 8
I'm not sure we're talking about the same thing. I agree that it is possible to think of the help panel as yet another toolstrip - for now lets simplify. Lets assume as an applications developer you dont want that as a feature - you want the panel to remained fixed in place.

The point I was trying to make is that there are more than four drop zones in word. We allow you to create more than one toolstrip container and place it anywhere you'd like, not necessarily on the edges. If you dont want the middle bit ( the content panel ) or even the other 3 drop zones, you can use individual toolstrip panels.

There are others - imagine a split container with two dock filled toolstrip containers, or just standalone ToolStripPanels docked along the edges of the splitter.

Thanks for your feedback and enthusiasm about the area!

Jessica
Developer, Windows Forms Team

Jessica at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 9
Jessica wrote:
I'm not sure we're talking about the same thing. I agree that it is possible to think of the help panel as yet another toolstrip - for now lets simplify. Lets assume as an applications developer you dont want that as a feature - you want the panel to remained fixed in place.

The point I was trying to make is that there are more than four drop zones in word. We allow you to create more than one toolstrip container and place it anywhere you'd like, not necessarily on the edges. If you dont want the middle bit ( the content panel ) or even the other 3 drop zones, you can use individual toolstrip panels.

That sounds well and good but it doesn't follow good design principles. As a matter of fact Benjamin Roe most notably applied Fitts' law to state that important controls should go at the edge of the screen. However, you could make the argument that once you place the fixed panel at the edge of the screen, the right edge is now the left edge of the fixed panel. But again, I ask, why not keep this as dockable tool windows to allow the user to make that decision? By placing a fixed tool window instead of a dockable tool window, you are limiting your users choice which again breaks the first law of good gui design -- dont make the UI a roadblock for the user to accomplish his tasks.

Jessica wrote:
There are others - imagine a split container with two dock filled toolstrip containers, or just standalone ToolStripPanels docked along the edges of the splitter.

I have imagined it and I'm horrified! However, as I've stated before, if you really truly feel this should be changed, suggest it in product feedback as a feature request, but most certainly not as a bug report. As was my original point, this is designed this way and is functioning as designed.

TobinTitus at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 10
jmw - it looks like we have this issue logged internally. If you would like to track it, you'll need to also file it through product feedback.

Jessica
Developer, Windows Forms Team

Jessica at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 11
You are welcome to have the last word on this, here's mine.

When we set out to build toolstrips, we decided that we didn't know 100% of the cases where/when/how folks were going to use them. This is a major reason why we decided to allow them anywhere within the client region, as opposed to being constrained to a portion of the non-client area.

Of course folks can place them in locations that don't meet great UI principles as set out by the Windows UI Gudelines or Alan Cooper or your aforementioned guide.

However, because the toolstrips are free to be placed anywhere, there are new possibilities in UI that you nor I have not imagined yet that may well fit into the spirit behind these guidelines. Even simple stuff - perhaps a translation form, vertically split with two panes, the top is entry in english, the bottom is output in french... and a little toolbar in the middle that activates the translation. Maybe its right, maybe its strange, who am I to judge?

We've decided to count on applications developers to build sensible applications with the libraries we've built, rather than restrict them from the start.

I hope this gives some insight into our reasoning.

Thanks,
Jessica
Developer, Windows Forms Team

Jessica at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...