473,503 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ToolStripPanel Layout problem

Hi,

I'm adding 5 ToolStrips to a ToolStripPanel (ToolStripContainer,
TopContainer) and see them ordered in three rows, starting on the left side.
I want to have it in one row all. Trying to join them using a new location
(toolstrip.Location = new Point(x,y) does not work. Is there any property,
which allows the Location setting not to be ignored or is there any property
helping to get the result as described?
In my special case the ToolStrips are located:
first ToolStrip in first row left aligned (last ToolStrip joined!)
next two ToolStrips in second row left aligned (bnoth are some smaller)
next two ToolStrips in third row.
It seems, that the TopContaier has not enough space on the right side.

Thanks for any help.

regards Michael
Mar 13 '07 #1
4 12507
VJ
Ha.. yes location, everything works, but there is a catch. You have added
them at design, that has to be cleared and then all panels be re-added.. So
use something like this in activate code of the form.. or if you are in MDI
environment, then use MDIChildActivate event..

TopToolStripPanel.Controls.Clear(); //Clear all for
current window
TopToolStripPanel.Join(toolbarMainMenu, 0); //Join the
MDI Menu First
TopToolStripPanel.Join(barFullScreen, 1); // join the
MDI's Tool Strip Bar
//Join any child toolstrip bars after in the order you
want..// location can also be used
TopToolStripPanel.Join(((ChildForm1)this.ActiveMdi Child).brEditInfo,
2);
TopToolStripPanel.Join(((ChildForm1)this.ActiveMdi Child).barFileToolbar,
2);

If there is another way, I would love to learn, and reduce the code we
have.. This is only thing that worked for us, after hours of struggle

VJ

"Michael Haberichter" <Ha*********@community.nospamwrote in message
news:CE**********************************@microsof t.com...
Hi,

I'm adding 5 ToolStrips to a ToolStripPanel (ToolStripContainer,
TopContainer) and see them ordered in three rows, starting on the left
side.
I want to have it in one row all. Trying to join them using a new location
(toolstrip.Location = new Point(x,y) does not work. Is there any property,
which allows the Location setting not to be ignored or is there any
property
helping to get the result as described?
In my special case the ToolStrips are located:
first ToolStrip in first row left aligned (last ToolStrip joined!)
next two ToolStrips in second row left aligned (bnoth are some smaller)
next two ToolStrips in third row.
It seems, that the TopContaier has not enough space on the right side.

Thanks for any help.

regards Michael


Mar 13 '07 #2
Hi Jeffrey,

Unfortunately I have a complex context, not so easy to reduce to a simple
scenario.
I have a tool-dll providing a baseclass earning from Form. Each type of form
I implement creates a desktop, containing elements depending on its type. In
this case the type is MAINFORM. The baseclass for MAINFORM creates a
ToolStripContainer, adds a Status to the BottomPanel, adds ToolStrips and the
Menu to the TopPanel. The ContentPanel is used as desp for the application.
The ToolStrips are passed in a parameterlist of strings (names of the
toolstrips) by the calling client program using the toolbox. At least the
baseclass builds dynamically the Toolstrips (and its Items).
For better control I set the backcolor from TopPanel to red and I see, that
the Menu takes the irst row, the ToolBar takes 4 rows. The rows are red over
the entire row, the toolstrips can be moved whereever I want.
Without setting a location all toolsttrips are located left aligned in three
rows. Controlling the location as you showed adding width of the previous
toolstrip to X, they are right aligned at postion approx. 1 inch from left
side.
(if I don't join the menu to the TopPanel, same behaviour, except the row of
the menu is not visible).

The code building:
....
_toolStripContainer = new XToolStripContainer(this); (X are my derivinngal
classes)
....
// Link Client Desk toContentPanel
_desk = new XPanel(isp);
Desk.AutoScroll = false;
Desk.Dock = DockStyle.Fill;
Desk.BorderStyle = BorderStyle.Fixed3D;
Desk.BackColor = SystemColors.AppWorkspace;
Desk.Parent = ContentPanel;

// Link TopPanel toClient Top StripPanel
// (my Stripücontainer Manager in a particular class)
AddStripPanel(CK.ClientTopContainer, TopToolStripPanel);
TopToolStripPanelVisible = Client.HasMenu | Client.HasTool;
TopToolStripPanel.BackColor = Color.Red;

// Link BottomPanel toClient Bottom StripPanel
AddStripPanel(CK.ClientBottomContainer, BottomToolStripPanel);
BottomToolStripPanelVisible = Client.HasStatus;

AddStripPanel(CK.ClientLeftContainer, LeftToolStripPanel);
LeftToolStripPanelVisible = false;
AddStripPanel(CK.ClientRightContainer, RightToolStripPanel);
RightToolStripPanelVisible = false;
....
Building if system is ready for run:

public void Run(string menu)
{
XToolStrip xts;
Stack<XToolStripstrips = new Stack<XToolStrip>();

CurrentMenu = MenuCollection[menu] as XTopMenu;
CurrentMenu.Build();

foreach (XStatusStrip ss in StatusStripCollection.Values)
{
ss.Build();
BottomPanel.Join(ss);
}
foreach (XToolStrip ts in ToolStripCollection.Values)
{
ts.Build();
// for order reverse in next step
strips.Push(ts);
}
int x = 3;
// now is in reverse order
while (strips.Count 0)
{
xts = strips.Pop();
TopPanel.Join(xts);
xts.Location = new Point(x, 0);
x = x + xts.Width + 3;
}

CurrentMenu.StripPanel.Join(CurrentMenu.MenuStrip, 0);
_toolStripContainer .Parent = Form;
}

Is there a way to attach a BMP? It would show better the situation.

Thanks for your support
reagrds Michael

""Jeffrey Tan[MSFT]"" wrote:
Hi Michael,

Sorry, I am not sure I understand your problem completely.

I have created a little sample project by adding a ToolStripContainer. Then
I select the TopToolStripPanel and added 5 ToolStrips from toolbox in
designer. I then used the following code to join these 5 ToolStrips into a
row one by one:

private void Form1_Layout(object sender, LayoutEventArgs e)
{
this.toolStrip1.Items.Add("ToolStrip1");
this.toolStrip2.Items.Add("ToolStrip2");
this.toolStrip3.Items.Add("ToolStrip3");
this.toolStrip4.Items.Add("ToolStrip4");
this.toolStrip5.Items.Add("ToolStrip5");

Point pt = new Point(3, 0);
this.toolStrip1.Location = pt;
this.toolStrip2.Location = new Point(this.toolStrip1.Width + pt.X, 0);
this.toolStrip3.Location = new Point(this.toolStrip1.Width +
this.toolStrip2.Width + pt.X, 0);
this.toolStrip4.Location = new Point(this.toolStrip1.Width +
this.toolStrip2.Width + this.toolStrip3.Width + pt.X, 0);
this.toolStrip5.Location = new Point(this.toolStrip1.Width +
this.toolStrip2.Width + this.toolStrip3.Width + this.toolStrip4.Width +
pt.X, 0);
}

It seems that it works well on my side without any problem(assuming there
is enough space in one row to contain all 5 ToolStips). However, their
orders may be flow if the width in one row can not contain all the 5
ToolStrips. Is this your problem?

I have attached the sample project in this reply.

Please feel free to feedback your concern, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights
Mar 15 '07 #3
Hi again,

sorry, but I made simplest poosible mistake. The ToolStripContainer was
added to the form as last step. Adding as first step and all runs perfectly.

Thanks again for your support.

regards
Michael

""Jeffrey Tan[MSFT]"" wrote:
Hi Michael,

Sorry, I am not sure I understand your problem completely.

I have created a little sample project by adding a ToolStripContainer. Then
I select the TopToolStripPanel and added 5 ToolStrips from toolbox in
designer. I then used the following code to join these 5 ToolStrips into a
row one by one:

private void Form1_Layout(object sender, LayoutEventArgs e)
{
this.toolStrip1.Items.Add("ToolStrip1");
this.toolStrip2.Items.Add("ToolStrip2");
this.toolStrip3.Items.Add("ToolStrip3");
this.toolStrip4.Items.Add("ToolStrip4");
this.toolStrip5.Items.Add("ToolStrip5");

Point pt = new Point(3, 0);
this.toolStrip1.Location = pt;
this.toolStrip2.Location = new Point(this.toolStrip1.Width + pt.X, 0);
this.toolStrip3.Location = new Point(this.toolStrip1.Width +
this.toolStrip2.Width + pt.X, 0);
this.toolStrip4.Location = new Point(this.toolStrip1.Width +
this.toolStrip2.Width + this.toolStrip3.Width + pt.X, 0);
this.toolStrip5.Location = new Point(this.toolStrip1.Width +
this.toolStrip2.Width + this.toolStrip3.Width + this.toolStrip4.Width +
pt.X, 0);
}

It seems that it works well on my side without any problem(assuming there
is enough space in one row to contain all 5 ToolStips). However, their
orders may be flow if the width in one row can not contain all the 5
ToolStrips. Is this your problem?

I have attached the sample project in this reply.

Please feel free to feedback your concern, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights
Mar 15 '07 #4
Hi Michael,

You are welcome. Is your problem fully resolved? If you still need any help
or have any concern, please feel free to feedback or post a new question,
thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
5622
by: Zak McGregor | last post by:
Hi all Are there any good solutions to aligning form field names and input boxes without resorting to tables? I am struggling to do this nicely at the moment. Thanks Ciao Zak
15
2306
by: Tamblyne | last post by:
This problem has got to have a simple solution and I can't be the first person who has ever handled it. Perhaps Google is no help because I'm not using the right terms? (I did find one post...
10
9173
by: Luke | last post by:
Hi. I am trying to make correct layout, here is an example of (dynamically generated content via jsp): http://localhost/www/layout.htm Most outer div is positioned absolute (if not then it...
0
3071
by: MLM450 | last post by:
Does anybody know how to load a ToolStrip's location within a ToolStripPanel? I have several ToolStrips and want them to remember their location from one session to the next. I have tried saving...
14
4814
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
0
1784
by: prasad chilamakuri | last post by:
when more than one tool strip is added to the ToolStripPanel which is docked to Top all the toolstrip items are placed as a stack. using Join() to add toolstrips to first row is not working. ...
1
1483
nev
by: nev | last post by:
winapp: when i dock = fill my toolstrip in a toolstrippanel, it doesn't fill
9
10955
by: weird0 | last post by:
How does C++ and C# solve the Diamond problem? With the help of interfaces that is. Can anyone elaborate ....... Regards
1
2900
by: stevedub | last post by:
I am having some trouble configuring my array to read from a sequential file, and then calling on that to fill an array of interests. I think I have the class set up to read the file, but when I run...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.