I am in the process of updating our VB.NET customizations to C# (Both attached, below). I am currently working on Issue Material. (Bolds added for easier reading.)
I am having a problem with getting access to an existing EPICOR textbox or whatever.
In VB.NET I’d use the following code.
Private withEvents txtPart as epiTextBox
Private withEvents txtRef, txtPart as epiTextBox
Private withEvents nbrQty as EpiNumericEditor
Private withEvents cmbMtl as EpiUltraCombo
Private withEvents btnOK,btnCancel as EpiButton
Private Sub IssueMaterialForm_Load(ByVal sender As Object, ByVal args As EventArgs)
nbrQty = CType(csm.GetNativeControlReference("4dad869d-7ffa-45c3-9bf2-bdb96edfb83b"), EpiNumericEditor)
cmbMtl = CType(csm.GetNativeControlReference("3c29bb2b-cc78-4cab-80c8-f004923fdbae"), EpiUltraCombo)
btnOK = CType(csm.GetNativeControlReference("43ce5d32-8e77-4d69-9a8e-6c33bd4da434"), EpiButton)
btnCancel = CType(csm.GetNativeControlReference("e3b58973-656f-42a3-8fe5-e362a0aeb57c"), EpiButton)EpiTextBox)
End sub
I have the following code for C#:
private EpiNumericEditor nbrQty;
private EpiUltraCombo cmbMtl;
private EpiButton btnOK;
private EpiButton btnCancel;
private void IssueMaterialForm_Load(object sender, EventArgs args)
{
txtToMtlPart = (EpiTextBox)csm.GetNativeControlReference("6e38f847-830d-400f-a3bd-937a4f1aee04");
txtRef = (EpiTextBox)csm.GetNativeControlReference("0ff0dfbb-1625-406e-9917-88f3cef0fd5e");
txtPart = (EpiTextBox)csm.GetNativeControlReference("26fb08e8-8d2e-4d2f-88e5-9f9a8797cc2b");
nbrQty = (EpiNumericEditor)csm.GetNativeControlReference("4dad869d-7ffa-45c3-9bf2-bdb96edfb83b");
cmbMtl = (EpiUltraCombo)csm.GetNativeControlReference("3c29bb2b-cc78-4cab-80c8-f004923fdbae");
btnOK = (EpiButton)csm.GetNativeControlReference("43ce5d32-8e77-4d69-9a8e-6c33bd4da434");
btnCancel = (EpiButton)csm.GetNativeControlReference("e3b58973-656f-42a3-8fe5-e362a0aeb57c");
}
##Testing code, compiles successfully, but nothing works when I enter or leave the nbrQty.
##Further reading, I’ve found that I need to add the following
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
this.IM_DataView = this.IM_Row.dataView;
this.IM_DataView.ListChanged += new ListChangedEventHandler(this.IM_DataView_ListChanged);
this.edvIM = ((EpiDataView)(this.oTrans.EpiDataViews["IM"]));
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.nbrQty.Leave += new System.EventHandler(this.nbrQty_Leave);
this.txtRef.Enter += new System.EventHandler(this.txtRef_Enter);
this.txtRef.Leave += new System.EventHandler(this.txtRef_Leave);
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
// 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.nbrQty.Leave -= new System.EventHandler(this.nbrQty_Leave);
this.txtRef.Enter -= new System.EventHandler(this.txtRef_Enter);
this.txtRef.Leave -= new System.EventHandler(this.txtRef_Leave);
this.btnOK.Click -= new System.EventHandler(this.btnOK_Click);
this.btnCancel.Click -= new System.EventHandler(this.btnCancel_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
I test the code and it compiles successfully, but when I close the form and reopen, I get the following error and can’t continue any further. Anything will be helpful.
Error Detail
============
Exception has been thrown by the target of an invocation.
Stack Trace
===========
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Epicor.Mfg.UI.Customization.CustomScriptMethodInvoker.InvokeScriptMethod(MethodInfo scriptMethod, Object[] parameters)
at Epicor.Mfg.UI.Customization.CustomScriptMethodInvoker.InvokeInitializeCustomCodeIfExists()
at Epicor.Mfg.UI.Customization.CustomScriptManager.TryActionShowExceptionBoxOrLogVerificationErrorIfException(Action action, String exceptionBoxTitle)
Inner Exception
===============
Object reference not set to an instance of an object.
Inner Stack Trace
=================
at Script.InitializeCustomCode()
IssueMaterialForm-VB.vb (8.5 KB)
IssueMaterialForm-Csharp.vb (9.2 KB)