Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ToolStripManager.Merge with NavToolBar
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01123541
Message ID:
01134286
Vues:
17
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform