0

Part of an application I'm working on involves a dynamic ToolStrip where items are added and removed depending on the application's state. Currently I'm storing the items in various independent ToolStrips and simply adding and removing them when necessary. The problem I'm having is this:

-If the new Toolstip has one item and I use the method AddRange, it's removed from the new Toolstrip, giving it an item count of 0.

-If the new Toolstrip has multiple items and I use AddRange, an ArgumentOutOfRange error is thrown.

Is there something about ToolStripItemCollections I'm unaware of that's causing this, or is there a better way to go about programming this?

Edit: Quick Example Code

ToolStrip oldToolStrip = new ToolStrip();
ToolStrip newToolStrip = new ToolStrip();

newToolStrip.Items.Add(new ToolStripTextBox());
newToolStrip.Items.Add(new ToolStripButton());

oldToolStrip.Items.AddRange(newToolStrip.Items);            

1 Answers1

0

There is a bug with the control: http://www.pcreview.co.uk/forums/possible-bug-toolstrip-items-addrange-t2900540.html

string.Empty
  • 10,393
  • 4
  • 39
  • 67