Customize 2nd MES menu button

Has anyone had success adding a second customized MES menu button? Have used the enclosed code successfully on one button, but my C# is not strong enough to know how I would add a second button.

// **************************************************
// Custom code for MESMenu
// Created: 3/12/2018 2:36:30 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
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 **

EpiButton btnDash;

public void InitializeCustomCode()
{
//Launch first button 
btnDash = (EpiButton)csm.GetNativeControlReference("83d9c21c-086c-4196-bce9-2e52fdd7b5de");

	// ** 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
this.btnDash.Click += new System.EventHandler(this.btnDash_Click);
}

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

	// End Custom Code Disposal
this.btnDash.Click -= new System.EventHandler(this.btnDash_Click);
}

private void MESMenu_Load(object sender, EventArgs args)
{
	// Add Event Handler Code
btnDash.ReadOnly=false;

}

private void btnDash_Click(object sender,System.EventArgs args)
{
//First button
ProcessCaller.LaunchForm(this.oTrans, “JCGO3004”);

}

}

The wizard will do everything for you. Draw and place the button, save, then go to the wizard and pick your second button. Then look in your code editor and you will see the wizard for adding the working parts of the code.

image

Side note, please check out the code block editor for the forum. It helps keep this place tidy.

We have added many buttons. So many actually we created our own tab. lol

Is there an error? or just not working?

1 Like

Probably missing a step.

First button works fine.

Create a second button, name the button, save. Highlight button in tree view

Do I then need to do something different in Wizards > Form Event Wizard?

When I go to script editor, I’m just seeing the code used for the first button.

That doesn’t matter.

Yes, the same steps you did to get the first button, but select the second button instead. See screen shot above.

1 Like

You’ll need to select your new custom control as Brandon mentioned. The only thing missing from Brandon’s screenshot, is you need to hit the right arrow button after you select the control and the click control event, then you click the update selected event code.

The update selected event code button is applying the text that appears in the control event code box on that wizard, which is populated by the control event selected in the list box in the top right.

1 Like