Avatar of Trygve Thayer
Trygve Thayer
Flag for United States of America asked on

C# Pull value from screen

We are using Epicor customization tools and need some help with passing a variable.  We know how to do it in VB but not C#   In the example below we are working on the private void epiButtonC1_Click(object sender, System.EventArgs args) event and will copycat to the other button click events once we find a solution.  There is a box on the screen where we are trying to get the information from it using the GUID and then pass it to the form we are opening.  The MessageBox in there is to check and see if the value shows up but that is not right either as it just shows "MyJob"


// **************************************************
// Custom code for MainController
// Created: 05/09/2018 2:44:06 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;

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 **
	private EpiTextBox MyJob;

	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.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
		this.epiButtonC2.Click += new System.EventHandler(this.epiButtonC2_Click);
		this.epiButtonC3.Click += new System.EventHandler(this.epiButtonC3_Click);
		this.epiButtonC4.Click += new System.EventHandler(this.epiButtonC4_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.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
		this.epiButtonC2.Click -= new System.EventHandler(this.epiButtonC2_Click);
		this.epiButtonC3.Click -= new System.EventHandler(this.epiButtonC3_Click);
		this.epiButtonC4.Click -= new System.EventHandler(this.epiButtonC4_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		MyJob = (EpiTextBox)csm.GetNativeControlReference("a214bbab-19c0-4575-8387-591adb7c0624");
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ContextValue = MyJob;
		lfo.IsModal = false;
		lfo.SuppressFormSearch = true;
		MessageBox.Show ("MyJob");
		ProcessCaller.LaunchForm (oTrans, "IMGO3005", lfo);		
	}

	private void epiButtonC2_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ContextValue = "MyJob";
		lfo.IsModal = false;
		lfo.SuppressFormSearch = true;
		ProcessCaller.LaunchForm (oTrans, "IMGO3001", lfo);
	}

	private void epiButtonC3_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ContextValue = "MyJob";
		lfo.IsModal = false;
		lfo.SuppressFormSearch = true;
		ProcessCaller.LaunchForm (oTrans, "JCGO3002", lfo);
	}

	private void epiButtonC4_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ContextValue = "MyJob";
		lfo.IsModal = false;
		lfo.SuppressFormSearch = true;
		ProcessCaller.LaunchForm (oTrans, "IMGO3014", lfo);
	}
}

Open in new window

VB ScriptC#

Avatar of undefined
Last Comment
Trygve Thayer

8/22/2022 - Mon
Misha

Where is  box on the screen ?
What specifically do you ask?
Trygve Thayer

ASKER
In the Epicor Tools there is a way to put a box on the screen and bind it to a field.  That box has a unique Guid.  In  VB code before we could do a Private WithEvents MyJob as EpiTextbox (My Job is just a variable I made up)  then we assign the variable to a textbox  MyJob=CType(csm.GetNativeControlReference("b9883534-0081-457e-9c79-abb38b41da22"),EpiTextBox)  then when we open a form we reference it as MyJob.text

Hope this is what you were looking for.
Trygve Thayer

ASKER
Still looking for some assistance on this issue.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Trygve Thayer

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.