Ce customizer montre comment intervenir sur l'affichage (ou non) des boutons gérant la grille des contacts dans la fiche clients.
Dans l'exemple ci-dessous, le bouton "Effacer toutes les lignes" est inaccessible et invisible.
Le code est construit sur base d'un customizer SigCli qui implémente ces interfaces :
Le code est le suivant :
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using MercatorUi;
using MercatorApi;
using System.Data;
using System.Data.SqlClient;
namespace SigCli
{
public class Customizer : MercatorUi.ICustomizers.IFormLoadCustomizer,
MercatorUi.ICustomizers.IFormClosedCustomizer
{
public void FormLoadCustomize(System.Windows.Forms.Form WindowsForm)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)WindowsForm;
List<Control> l = sigForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigGrids.Contacts));
if (l.Count > 0)
{
MercatorUi.Forms.Sig.SigGrids.Contacts contacts = (MercatorUi.Forms.Sig.SigGrids.Contacts)l[0];
contacts.AssociatedPanelCreated += new MercatorUi.MovableControls.MovableGrid.AssociatedPanelCreatedHandler(contacts_AssociatedPanelCreated); //
}
}
public void FormClosedCustomize(System.Windows.Forms.Form WindowsForm)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)WindowsForm;
List<Control> l = sigForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigGrids.Contacts));
if (l.Count > 0)
{
MercatorUi.Forms.Sig.SigGrids.Contacts contacts = (MercatorUi.Forms.Sig.SigGrids.Contacts)l[0];
contacts.AssociatedPanelCreated -= new MercatorUi.MovableControls.MovableGrid.AssociatedPanelCreatedHandler(contacts_AssociatedPanelCreated); //
}
}
private void contacts_AssociatedPanelCreated(object sender, MercatorUi.MovableControls.MovableGrid.AssociatedPanelCreatedEventArgs e)
{
foreach (Control c in e.AssociatedPanel.Controls)
if (c.Name == "buttonXDelete")
{
c.Visible = false;
c.Enabled = false;
}
}
}
}