Le code repris ci-dessous montre comment ajouter une entrée dans le menu contextuel du LinesEditor de la BillingForm. Le code à exécuter quand on sélectionne ce menu doit être placé dans la méthode mnuTest_Click.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
using MercatorApi;
using MercatorUi;
using System.Data.SqlClient;
namespace Billing
{
public class Customizer : MercatorUi.ICustomizers.IBillingEngineCreated, MercatorUi.ICustomizers.IBillingEngineClosed
{
public void BillingEngineCreated(MercatorUi.Engine.Gescom.BillingEngine BillingEngine)
{
BillingEngine.BillingFormLoaded += new EventHandler(BillingEngine_BillingFormLoaded);
}
public void BillingEngineClosed(MercatorUi.Engine.Gescom.BillingEngine BillingEngine)
{
BillingEngine.BillingFormLoaded -= new EventHandler(BillingEngine_BillingFormLoaded);
}
void BillingEngine_BillingFormLoaded(object sender, EventArgs e)
{
MercatorUi.Engine.Gescom.BillingEngine billingEngine = (MercatorUi.Engine.Gescom.BillingEngine)sender;
if (billingEngine.BillingForm.LinesEditor != null)
{
billingEngine.BillingForm.LinesEditor.Grid.ContextMenuStripGrid.Items.Add(new ToolStripSeparator());
ToolStripMenuItem mnuTest = new ToolStripMenuItem("Menu de Test");
mnuTest.Click += new EventHandler(mnuTest_Click);
billingEngine.BillingForm.LinesEditor.Grid.ContextMenuStripGrid.Items.Add(mnuTest);
}
}
void mnuTest_Click(object sender, EventArgs e)
{
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)MercatorUi.Globals.Main.WonTopForm();
MercatorUi.Engine.Gescom.BillingEngine billingEngine = billingForm.BillingEngine;
...
}
}
}