views:

29

answers:

2

C# WinForms: I would like to have two Toolbars But I also want them to be at the same line . I mean I do Not want one of them to be below or over the other them. so they will be in tow lines which is I do not want.

How can I do this?

+1  A: 

I'm assuming you're using the visual studio designer..if not, let me know.
Put down a ToolStrip Container, change it's visibility to be (assuming you want it at the top of your app) top only, then click "Dock Fill in Form"

Now add drag two toolstrips onto the container. Presto :-)

Edit:

Per your requirements, it gets a bit tricky, but not so bad. Click on your toolstrip so it has the small white box in the upper left hand corner, and the small triangle in the upper right. Click the triangle and change Dock to "None" Now manually stretch it to fill half the screen/whatever and do the same for the second toolbar.

Only problem with this approach is that occasionally, i've noticed visual studio "repositioning" the toolbars a pixel or two randomly after a compile. So, double check before releasing to the customer :-D

Caladain
True, Visual Studio Designerthanks but I cannot use ToolStrip container... Here is the situation: I already do have a ToolStrip on my form..lets call it Original toolstrip ... now I wanna add a second toolstrip to it , and I want its location to be at the right hand side of the Original one.... Cannot use StripContainer at this moment because I had not used it from beginning in my project
BDotA
Updated my post. Let me know if that fixes your issue
Caladain
Ok, it helps, so I will set the Dock to None, so I can change the location of toolbars manually. It works in a test app that I created now but I hope there are not more complexity with it at my real project. Thanks Sir.
BDotA
+1  A: 

Add a FlowLayoutPanel to your Form (AutoSize=True;AutoSizeMode=GrowAndShrink;Dock=Top;FlowDirection=LeftToRight;WrapContents=True). Then add the two ToolStrip controls to the FlowLayoutPanel (Dock=Top);

The ToolStrips may wrap, depending on the width of the Form.

Adel Hazzah