ToolStripPanel Layout problem

G

Guest

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
 
V

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.ActiveMdiChild).brEditInfo,
2);
TopToolStripPanel.Join(((ChildForm1)this.ActiveMdiChild).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
 
G

Guest

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
 
G

Guest

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]" 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
 
J

Jeffrey Tan[MSFT]

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/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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top