In het hier gegeven voorbeeld kunt u een standaardwaarde instellen in een kolom van de grid van de tarieven voor klanten.
In ons geval is dit het veld "date_fin".
Dit systeem is beschikbaar in alle grids met "Toevoegen / Verwijderen" knoppen van de signaletieken.
De code is als volgt :
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using MercatorApi;
using MercatorExtensions;
using MercatorUi;
using MercatorDatabase;
using System.Windows.Forms;
namespace SigCli
{
public class Customizer :
MercatorUi.ICustomizers.IFormLoadCustomizer,
MercatorUi.ICustomizers.IFormClosedCustomizer
{
public void FormLoadCustomize(Form WindowsForm)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)WindowsForm;
List<Control> l = sigForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigGrids.TarCli));
foreach (Control cTarCli in l)
{
MercatorUi.Forms.Sig.SigGrids.TarCli tarCli = (MercatorUi.Forms.Sig.SigGrids.TarCli)cTarCli;
tarCli.AssociatedPanelCreated += TarCli_AssociatedPanelCreated;
}
}
public void FormClosedCustomize(Form WindowsForm)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)WindowsForm;
List<Control> l = sigForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigGrids.TarCli));
foreach (Control cTarCli in l)
{
MercatorUi.Forms.Sig.SigGrids.TarCli tarCli = (MercatorUi.Forms.Sig.SigGrids.TarCli)cTarCli;
tarCli.AssociatedPanelCreated -= TarCli_AssociatedPanelCreated;
}
}
private void TarCli_AssociatedPanelCreated(object sender, MercatorUi.MovableControls.MovableGrid.AssociatedPanelCreatedEventArgs e)
{
MercatorUi.MovableControls.Tools.GridButtons buttons = (MercatorUi.MovableControls.Tools.GridButtons)e.AssociatedPanel;
buttons.BeforeClickInGridButtons += new MercatorUi.MovableControls.Tools.GridButtons.BeforeClickInGridButtonsHandler(buttons_BeforeClickInGridButtons);
buttons.AfterClickInGridButtons += Buttons_AfterClickInGridButtons;
buttons.Disposed += Buttons_Disposed;
}
private void Buttons_Disposed(object sender, EventArgs e)
{
MercatorUi.MovableControls.Tools.GridButtons buttons = (MercatorUi.MovableControls.Tools.GridButtons)sender;
buttons.AfterClickInGridButtons -= Buttons_AfterClickInGridButtons;
buttons.Disposed -= Buttons_Disposed;
}
private void Buttons_AfterClickInGridButtons(object sender, MercatorUi.MovableControls.Tools.AfterClickInGridButtonsEventArgs e)
{
MercatorUi.MovableControls.Tools.GridButtons buttons = (MercatorUi.MovableControls.Tools.GridButtons)sender;
if ((e.ClickedButtonX == MercatorUi.MovableControls.Tools.ButtonsForGrid.Add) || (e.ClickedButtonX == MercatorUi.MovableControls.Tools.ButtonsForGrid.Insert))
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)buttons.FindForm();
List<Control> l = sigForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigGrids.TarCli));
foreach (Control cTarCli in l)
{
MercatorUi.Forms.Sig.SigGrids.TarCli tarCli = (MercatorUi.Forms.Sig.SigGrids.TarCli)cTarCli;
tarCli.Grid.CurrentRow.Cells["date_fin"].Value = new DateTime(2999, 12, 31);
}
}
}
}
}