I'm trying to create a custom BindingNavigator control in with some extra ToolStripButton (Edit
and ExportToExcel
).
The ToolStripButton is added to the BindingNavigator, but I cannot select this new ToolStripButton, e.g., to add code in its Click event handler. Actually, the ToolStripButtons appear locked.
Here is my code and an image that should describe the problem:
using System.Windows.Forms;
public class BindingNavigator : System.Windows.Forms.BindingNavigator
{
public ToolStripButton btnEdit;
public ToolStripButton btnExcelExport;
public BindingNavigator()
{
this.LayoutCompleted += BindingNavigator_LayoutCompleted;
}
public void BindingNavigator_LayoutCompleted(object sender, System.EventArgs e)
{
if (this.Items.Contains(btnEdit))
return;
if (this.Items.Count >= 11)
{
btnEdit = new ToolStripButton();
btnEdit.Image = global::BaseControls.Properties.Resources.Edit___16x16;
btnEdit.Name = "btnEdit";
this.Items.Insert(10, btnEdit);
this.Items.Add(new ToolStripSeparator());
btnExcelExport = new ToolStripButton();
btnExcelExport.Image = global::BaseControls.Properties.Resources.Excel___16x16;
btnExcelExport.Name = "btnExcelExport";
this.Items.Insert(13, btnExcelExport);
}
}
}