Screen customization: tab sequence changing after code sets focus

I’m working on creating some automation in a Updatable Dashboard that I built to run Refresh All after tabbing out of a field, then reset the Focus back to that same field. I have it working, at least for the first time that it runs. When I run the sequence a second time the cursor will leave the field and run the Refresh All process and the focus will get looped back correctly, but then I can watch the cursor leave the field again like it was tabbed out. The weird part is that this ghost tab will NOT put the cursor into the next field in the tab sequence. I can shift-tab and the cursor will come back to the first field, but hitting tab will send it into the ether.

I’m not a developer by any means so I have no idea how to do a process trace in a screen to see what C# functions are being called. If anyone can point me to an easy way to do this, maybe that would help figure out what’s causing the extra Leave on the field. Has anyone else experienced this before? At this point I’m stumped on what to do next.

My code is below in case it’s apparent to anyone that I actually screwed this up (entirely possible).

[ninja edit]: I created this code based on this thread: Dashboard Refresh All Issue

// **************************************************
// Custom code for MainController
// Created: 1/17/2022 11:55:25 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.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 **
	private EpiTextBox txtEquip_EquipID;
	private EpiTextBox txtEquip_Description;
	private static Boolean RefreshAll = false;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
		txtEquip_EquipID = (EpiTextBox)csm.GetNativeControlReference("0b1450a6-4568-4c25-9202-a6528c59a6e9");
		txtEquip_Description = (EpiTextBox)csm.GetNativeControlReference("36335eb4-8609-4bf3-b80a-251c243b098e");
		txtEquip_EquipID.Leave += new System.EventHandler(txtEquip_EquipID_Leave);
		txtEquip_Description.TextChanged += new System.EventHandler(txtEquip_Description_TextChanged);

		// 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
		txtEquip_EquipID.Leave -= new System.EventHandler(txtEquip_EquipID_Leave);
		txtEquip_Description.TextChanged -= new System.EventHandler(txtEquip_Description_TextChanged);

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}
	private void ResetMe()
		{
		//RefreshAll = true;
		MainController.AppControlPanel.HandleToolClick("RefreshAllTool", new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshAllTool"], null));
		}

	private void txtEquip_EquipID_Leave(object sender, System.EventArgs args)
	{
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		//string message = "Leave has happened";
		//MessageBox.Show(txtEquip_EquipID.Text);
		if (RefreshAll == false && txtEquip_EquipID.Text!="")
		//if (txtEquip_EquipID.Text!="")
		{
			//case "Equip_EquipID":
			RefreshAll = true;
			ResetMe();
			//break;
		}
	}


	private void txtEquip_Description_TextChanged(object sender, System.EventArgs args)
	{
		//Add Event Handler Code
		if (RefreshAll == true && txtEquip_Description.Text != "")
		//if (txtEquip_Description.Text != "")
		{
			//MessageBox.Show("Desc has changed");
			RefreshAll = false;
			txtEquip_EquipID.Value = "";
			txtEquip_EquipID.Focus();
			
		}
	}

} ```