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<XToolStrip> strips = 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]" said:
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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights