Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ToolStripManager.Merge with NavToolBar
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01123541
Message ID:
01134286
Views:
16
Patrick,

It seems like the ToolStripManager.Merge does not work? I think I have a working solution by manually merging the ToolStrips. Here is what I did:

1. In the form, override the CreateNavToolBar method:

protected override void CreateNavToolBar()
{
base.CreateNavToolBar();

// manual merge
for (int i = 0, i < MyTools.Items.Count; i++)
{
this.NavToolBar.Items.Add(MyTools.Items[i]);
}
}

2. In MyTools which is a subclass of mmToolStrip, I use the designer to add buttons to the items collection property. For instance, you can add framework buttons (ButtonNew, ButtonDelete, etc.) or your own custom buttons.

3. In the click event of the button, you can get a reference to the active form and call the appropriate method:

private void ButtonSearch_Click(object sender, EventArgs e)
{
// get a reference to the active form
Form ActiveFormObj = mmAppDesktop.MainForm.GetActiveForm();
mmBusinessForm BusinessForm = ActiveFormObj as mmBusinessForm;

if (BusinessForm != null)
{
// call a form method
BusinessForm.Search();
}
}

It took me a while to get here, but this works well.

Kevin,

Maybe this could be handled with a Factory method instead overriding CreateNavToolBar on each form?

Kind Regards,

Mat
Matthew Kennedy
Decision Support Technology Inc.

"I try to take one day at a time, but sometimes several days attack me all at once." ~ Ashleigh Brilliant

New Jersey Dot Net User Group
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform