ToolStripManager.Merge does not work with BindingNavigator

I can't merge a toolstrip into a binding navigator or merge the binding navigator into an existing toolstrip. To reproduce the problem add a toolstrip and a bindingnavigator to a form and call:

MessageBox.Show(ToolStripManager.Merge(toolStrip1, bindingNavigator1).ToString());

Any idea why I am seeing this behavior. The documentation mentions nothing special about the binding navigator merge behavior

Thanks!
Mike



Answer this question

ToolStripManager.Merge does not work with BindingNavigator

  • KirkAtCenterstance

    Mike,

    The ToolStrip sports an AllowMerge property that defaults to false. So by default you cannot merge anything into a BindingNavigator. The BindingNavigator docs do not indicate that the class prevents this, so you might be able to change the property in code to allow this to happen. I'd be interested in knowing if this works, so let us know.

    Erik



  • joelm9898

    The AllowMerge for the bindingNavigator1 and toolStrip1 defaulted to true, but to be sure I added this code:

    MessageBox.Show(toolStrip1.AllowMerge.ToString());
    MessageBox.Show(bindingNavigator1.AllowMerge.ToString());

    Both returned true. I looked at the BindingNavigator code using refector and couldn't find any evidence of it messing with the AllowMerge property. If you want to see a really wierd exception that tells me there is a bug somewhere try the following code:

    bindingNavigator1.Items.AddRange(toolStrip1.Items);

    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    at System.Collections.ArrayList.get_Item(Int32 index)
    at System.Windows.Forms.ToolStripItemCollection.get_Item(Int32 index)
    at System.Windows.Forms.ToolStripItemCollection.AddRange(ToolStripItemCollection toolStripItems)


  • ToolStripManager.Merge does not work with BindingNavigator