/// <include file='doc\ToolBar.uex' path='docs/doc[@for="ToolBar.InsertButton"]/*' />
/// <devdoc>
/// <para>Inserts a button at a given location on the toolbar control.</para>
/// </devdoc>
private void InsertButton(int index, ToolBarButton value) {
if (value == null)
throw new ArgumentNullException("value");
if (index < 0 || ((buttons != null) && (index > buttonCount)))
throw new ArgumentOutOfRangeException("index", SR.GetString(SR.InvalidArgument, "index", index.ToString(CultureInfo.CurrentCulture)));
// insert the button into our local array, and then into the
// real windows ToolBar control
//
Insert(index, value);
if (IsHandleCreated) {
NativeMethods.TBBUTTON tbbutton = value.GetTBBUTTON(index);
UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_INSERTBUTTON, index, ref tbbutton);
}
UpdateButtons();
}