Calculate EpiUltraGrid Column

Hi,
I want to calculate charge amount in Sales Order>Order Misc Charges based on 2 UD fields that I’ve created Price & Quantity, on lost focus event of Quantity cell.

Any help will be highly appreciated.

Thanks.

Try the following on a customization of the Order Entry form:

  1. Add public EpiUltraGrid grdHeadMiscChrg; to the public class Script{...} section.
  2. Add grdHeadMiscChrg = (EpiUltraGrid)csm.GetNativeControlReference("72e8dbae-9bf8-4a5d-80a1-076d1bbf3d6f"); to the InitialzeCustomCode function
  3. Add this.grdHeadMiscChrg.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdHeadMiscChrg_AfterCellUpdate); right after the line added in step 2.
  4. Add this.grdHeadMiscChrg.AfterCellUpdate -= new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdHeadMiscChrg_AfterCellUpdate); to the DestroyCustomCode` function
  5. Create a function named private void grdHeadMiscChrg_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs args), and place your code in there.

Here’s the whole Code of an example that shows a message box after leaving a cell (tha has been changed) in that grid.

Summary
// **************************************************
// Custom code for SalesOrderForm
// Created: 1/2/2020 9:02:08 AM
// **************************************************

extern alias Erp_Contracts_BO_AlternatePart;
extern alias Erp_Contracts_BO_SalesOrder;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_RMAProc;
extern alias Erp_Contracts_BO_OrderDtlSearch;
extern alias Erp_Contracts_BO_OrderHist;
extern alias Erp_Contracts_BO_QuoteDtlSearch;
extern alias Erp_Contracts_BO_SerialNumberSearch;
extern alias Erp_Contracts_BO_ShipTo;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
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 EpiUltraGrid grdHeadMiscChrg;
	
    
	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

		// End Wizard Added Custom Method Calls
		grdHeadMiscChrg = (EpiUltraGrid)csm.GetNativeControlReference("72e8dbae-9bf8-4a5d-80a1-076d1bbf3d6f");
		this.grdHeadMiscChrg.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdHeadMiscChrg_AfterCellUpdate);
		
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal
	   this.grdHeadMiscChrg.AfterCellUpdate -= new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdHeadMiscChrg_AfterCellUpdate);
		
		// End Custom Code Disposal
	}

	
	   private void grdHeadMiscChrg_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs args)
	{
		// ** Place Event Handling Code Here **
		MessageBox.Show("Built-in Grid AfterCellUpdate");
	}
	
	
}

You’ll need to add code to determine which cell was just changed.

1 Like

Thanks alot Calvin for your time and consideration, code that you provided really helped me, it was like a stepping stone for this requirement.
Regards,
Faez