Is there a way to suppress a context menu entirely?

Trying to stop users from right-clicking their way to ‘Lot Search’ from the Issue Material screen in MES and randomly selecting lots. Any better suggestions on how to stop them from doing this?

1 Like

Have you looked at Context Menu Maintenance off the main menu?

A few possibilities to do this for just the Issue Material screen:

  1. Customization: Hide the lot field off-screen, add another text box in front of the panel, and have the lot field filled on Text Changed event of the new field.

  2. Process Calling Maintenance: have Lot Search call a menu item that does nothing only when called from the Issue Material screen. You would also need to apply this to Lot Tracker and Lot Entry when called from Issue Material.

  3. Context menu maintenance for individual users, but this affects every occurrence of Lot Number.

  4. A good caning for non-compliant users…

Yes, I have, but I am unsure how to figure out for sure which Context Menu it’s using. I’ve also tried changing it to other values I saw in the Context Menu maintenance, and I have tried clearing out the entries for LotSelectUpdate.LotNum et al. I guess I don’t know what CustomContextOnly means???

2019-03-05_21h11_24

James, #4 was my suggestion back when they asked me to hide the Lot Number button (which also triggered the search). Now it’s personal because they’ve outsmarted me with a right-click!!!

Probably the easiest way is to just use code like this in the Issue Material Form. This will disable the Lot Search context.

// **************************************************
// Custom code for IssueMaterialForm
// Created: 3/6/2019 6:32:39 AM
// **************************************************

extern alias Erp_Contracts_BO_IssueReturn;
extern alias Erp_Contracts_BO_JobEntry;
extern alias Erp_Contracts_BO_JobAsmSearch;
extern alias Erp_Contracts_BO_JobMtlSearch;

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 **

	private EpiDataView edvIM;
	// 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

		// 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

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
		EpiContextToolsManager.AfterBuildContextMenu -= new ContextToolHandler(EpiContextToolsManager_AfterBuildContextMenu);
	}

	private void IssueMaterialForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		EpiContextToolsManager.AfterBuildContextMenu += new ContextToolHandler(EpiContextToolsManager_AfterBuildContextMenu); 
	}

	private void EpiContextToolsManager_AfterBuildContextMenu(object sender, ContextToolEventArgs e) 
	{ 
		foreach (Infragistics.Win.UltraWinToolbars.ToolBase tool in e.ContextMenuPopup.Tools) 
		{ 
			if (tool.SharedProps.Caption == "Lot Search") tool.SharedProps.Enabled = false; 
		} 
	} 

}
2 Likes

Dan, it would be impossible for me to love you more. This worked perfectly. Thanks!