Met de hier beschreven customizer kan de naam van de derde partij standaard worden weergegeven in het eerste raster van de Ondervraging voor commerciële artikels. Alsof de gebruiker het contextmenu "Toon Naam Derde" had geselecteerd.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorExtensions;
using MercatorUi;
using System.Windows.Forms;
using System.Linq;
namespace SigStock
{
public class Customizer : MercatorUi.ICustomizers.IFormLoadCustomizer, MercatorUi.ICustomizers.IFormClosedCustomizer
{
public void FormLoadCustomize(Form windowsForm)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)windowsForm;
var stockInterro = sigForm.MovableControls.Values.OfType<MercatorUi.Forms.Sig.SigObjects.StockInterro>().FirstOrDefault();
if (stockInterro != null)
stockInterro.Grid1.StandardColumnsCreated += Grid1_StandardColumnsCreated;
}
public void FormClosedCustomize(Form windowsForm)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)windowsForm;
var stockInterro = sigForm.MovableControls.Values.OfType<MercatorUi.Forms.Sig.SigObjects.StockInterro>().FirstOrDefault();
if (stockInterro != null)
stockInterro.Grid1.StandardColumnsCreated -= Grid1_StandardColumnsCreated;
}
private void Grid1_StandardColumnsCreated(object sender, EventArgs e)
{
var grid1 = (MercatorUi.GridPro.DataGridViewXPro)sender;
string menuString = Api.Proper(_Divers.Iif_langue(Globals.Langue, "Show Thirdp. Name", "Derdepers. Naam Tonen", "Montrer Nom Tiers"));
var mnuToggleName = grid1.ContextMenuStripGrid.Items.OfType<ToolStripMenuItem>().Where(p => p.Text == menuString).FirstOrDefault();
if ((mnuToggleName != null) && !mnuToggleName.Checked)
mnuToggleName.PerformClick();
}
}
}