When custom CheckBox is Checked, I’d like the custom UltraCombo box to become visible and conversely, when custom CheckBox is Unchecked, I’d like the UltraCombo box to not be visible.
The C# code I have compiles successfully, however, the functionality is not working.
Here is the code. I am not sure what I am missing. I thought this would be a trivial customization.
// **************************************************
// Custom code for PartForm
// Created: 12/11/2017 12:38:55 PM
// **************************************************
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_PartPlantSearch;
extern alias Erp_Contracts_BO_PO;
extern alias Erp_Contracts_BO_PartOnHandWhse;
extern alias Erp_Contracts_BO_Vendor;
extern alias Erp_Contracts_BO_VendorPPSearch;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using Infragistics.Win;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiCheckBoxC2 = ((EpiCheckBox)csm.GetNativeControlReference("0e61b127-38ad-46e5-81ba-5d6442127112"));
this.epiUltraComboC1 = ((EpiUltraCombo)csm.GetNativeControlReference("5a4fe7b6-2781-49df-893b-8d82d5fcdd7b"));
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.epiCheckBoxC2.CheckedChanged -= new System.EventHandler(this.epiCheckBoxC2_CheckChanged);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void epiCheckBoxC2_CheckChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
if (this.epiCheckBoxC2.Checked == true)
{
epiUltraComboC1.Visible = true;
}
else
{
epiUltraComboC1.Visible = false;
}
}
}
I think the way Epicor handles windows forms is a little weird. There are events and things that happen that we don’t get any visibility into. That is to say, I haven’t used the visible property with any success.
Instead, I often use the enabled property to enable or disable the control. Give that a shot! Good luck!
Ugh! When I change the .Visible attribute to either .Enabled or .Hidden, I then receive a compile error.
Compiling Custom Code …
----------errors and warnings------------
Error: CS1061 - line 69 (863) - ‘Ice.Lib.Framework.EpiUltraCombo’ does not contain a definition for ‘Hidden’ and no extension method ‘Hidden’ accepting a first argument of type ‘Ice.Lib.Framework.EpiUltraCombo’ could be found (are you missing a using directive or an assembly reference?)
Error: CS1061 - line 73 (867) - ‘Ice.Lib.Framework.EpiUltraCombo’ does not contain a definition for ‘Hidden’ and no extension method ‘Hidden’ accepting a first argument of type ‘Ice.Lib.Framework.EpiUltraCombo’ could be found (are you missing a using directive or an assembly reference?)
Would you mind posting the code you used, so I can follow its logic? I am not asking for the exact syntax of what my code should be as I will not learn this way, but if I have something to follow I should be able to adapt to my purposes and will retain it for the next time I need something similar!
//these will only work if these are exposed on the epicor control (I don't recall if they are)
myEpiUltraCombo.Hide();
myEpiUltraCombo.Show();
//or
(Control)myEpiUltraCombo.Hide()
(Control)myEpiUltraCombo.Show()
(Control)myEpiUltraCombo.Visible = true;
(Control)myEpiUltraCombo.Visible = false;
Funny thing is, that is the exact code I had entered myself. It compiles successfully, but appears to not hide the combobox when unchecked. I’m perplexed.
That is exactly what the issue was. It works as expected now. I didn’t even notice that I had not entered code to initialize it. Thanks so much Todd! I appreciate it.