none
ToolStripPanel.Join() does not work... RRS feed

  • Question

  • I have seen heaps of questions in my searching but no answers.  I have a ToolStripPanel and have added a MenuStrip and two ToolStrips.  I want the two ToolStrips to be on the same row (so two rows in total) but I end up with them on three rows.  When I drag them round they will go on two rows.  I have tried every combination of the join methods and everything elses suggested on other forums but I can not programmatically put these ToolStrips on to the same row!!!

                topToolStripPanel = new ToolStripPanel();
                topToolStripPanel.Orientation = Orientation.Horizontal;
                topToolStripPanel.Dock = DockStyle.Top;
                topToolStripPanel.Join(this.menuStrip, 0);
                topToolStripPanel.Join(this.projectToolStrip, 1);
                topToolStripPanel.Join(this.fileToolStrip, 1);
    Monday, October 27, 2008 8:33 AM

Answers

  • Aaaarrggghhhh...  after about three hours I have worked it out...  The ToolStripPanel control must be added before adding the ToolStrip items are if the rows specified in the Join method are to be used as expected so...

                topToolStripPanel = new ToolStripPanel();
                topToolStripPanel.Orientation = Orientation.Horizontal;
                topToolStripPanel.Dock = DockStyle.Top;
                topToolStripPanel.Join(this.menuStrip, 0);
                topToolStripPanel.Join(this.projectToolStrip, 1);
                topToolStripPanel.Join(this.fileToolStrip, 1);
                this.Controls.Add(topToolStripPanel);

    does not work but...

                topToolStripPanel = new ToolStripPanel();
                topToolStripPanel.Orientation = Orientation.Horizontal;
                topToolStripPanel.Dock = DockStyle.Top;
                this.Controls.Add(topToolStripPanel);
                topToolStripPanel.Join(this.menuStrip, 0);
                topToolStripPanel.Join(this.projectToolStrip, 1);
                topToolStripPanel.Join(this.fileToolStrip, 1);

    does place the ToolStrips on the same row...

    • Marked as answer by MTBAsh Monday, October 27, 2008 8:53 AM
    Monday, October 27, 2008 8:53 AM