Epicor 10 Editing All Controls on a Page with out Hardcoding Input Names

Hey All,
While combing through this forum for nuggets of configurator code wisdom, I came across pieces of code which I was able to string together. The following code will take every control (except rectangles) and place them in to lists which can be iterated through to make property changes to all controls, or more specific changes if you have a good control naming convention. This code sets everything invisible or visible depending on a checkbox. I hope people find good uses to put this to.

//Lists to hold all the different control types
var decList = new List<Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiNumericEditor, System.Decimal>> ();
var chkList = new List<Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiCheckBox, System.Boolean>> ();
var chrList = new List<Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiTextBox, System.String>> ();
var cmbList = new List<Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiUltraCombo, System.String>> ();
var btnList = new List<Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiButton, System.String>> ();

//looping through all of the controls on the page gives the inputName, which is used to call for the instance of the control so it is added to the respective list
foreach (Control ctrl in Inputs.PriTotal_dec.Control.Parent.Controls)
{
    if (ctrl is Ice.Lib.Framework.EpiNumericEditor)
    {
        decList.Add ((InputControlValueBound<Ice.Lib.Framework.EpiNumericEditor, System.Decimal>) Inputs[ctrl.Name.ToString ()].Value);
    }
    if (ctrl is Ice.Lib.Framework.EpiCheckBox)
    {
        chkList.Add ((InputControlValueBound<Ice.Lib.Framework.EpiCheckBox, System.Boolean>) Inputs[ctrl.Name.ToString ()].Value);
    }
    if (ctrl is Ice.Lib.Framework.EpiTextBox)
    {
        chrList.Add ((InputControlValueBound<Ice.Lib.Framework.EpiTextBox, System.String>) Inputs[ctrl.Name.ToString ()].Value);
    }
    if (ctrl is Ice.Lib.Framework.EpiUltraCombo)
    {
        cmbList.Add ((InputControlValueBound<Ice.Lib.Framework.EpiUltraCombo, System.String>) Inputs[ctrl.Name.ToString ()].Value);
    }
    if (ctrl is Ice.Lib.Framework.EpiButton)
    {
        btnList.Add ((InputControlValueBound<Ice.Lib.Framework.EpiButton, System.String>) Inputs[ctrl.Name.ToString ()].Value);
    }
}

//looping through each of the lists of control instances, set all visible or invisible. 
foreach (Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiNumericEditor, System.Decimal> ctrl in decList)
{
    if (Inputs.DebugMode_chk.Value) ctrl.Invisible = true;
    else ctrl.Invisible = false;
}
foreach (Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiCheckBox, System.Boolean> ctrl in chkList)
{
    if (Inputs.DebugMode_chk.Value) ctrl.Invisible = true;
    else ctrl.Invisible = false;
}
foreach (Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiTextBox, System.String> ctrl in chrList)
{
    if (Inputs.DebugMode_chk.Value) ctrl.Invisible = true;
    else ctrl.Invisible = false;
}
foreach (Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiUltraCombo, System.String> ctrl in cmbList)
{
    if (Inputs.DebugMode_chk.Value) ctrl.Invisible = true;
    else ctrl.Invisible = false;
}
foreach (Erp.Shared.Lib.Configurator.InputControlValueBound<Ice.Lib.Framework.EpiButton, System.String> ctrl in btnList)
{
    if (Inputs.DebugMode_chk.Value) ctrl.Invisible = true;
    else ctrl.Invisible = false;
}
2 Likes

You’re a hero for posting this.