Ok, UNCLE! -> Help, what am I missing?!

Ok please help.

I’ve got an EpiDataView bound to the “Origin” table in dsRate.
I’m creating some dynamically added controls to a form.

They show up, but have no data, and even attaching an event to Click
does nothing.

What am I missing?

private void ShowValidation()
{
	int lastBottomPos = 0;
	foreach(DataColumn col in dsRate.Tables["Origin"].Columns)
	{
		EpiTextBox newTextBox = new EpiTextBox()
		{
			Width = thisForm.ClientSize.Width / 2,
			Height = 22,
			Left = 0,
			Top = lastBottomPos,
			Name = "txt" + col.ColumnName,
			Parent = thisForm
		};
		
		newTextBox.EpiBinding = "Origin." + col.ColumnName;

		//Even this doesn't work!
		newTextBox.Click += (s, e) =>
		{
			Console.Beep(500, 125);
		};

		lastBottomPos = newTextBox.Top + newTextBox.Height + 5;
		
		thisForm.Controls.Add(newTextBox);
	}

	edvOrigin.Row = 0;

	edvOrigin.Notify(new EpiNotifyArgs(oTrans, edvOrigin.Row, EpiTransaction.NotifyType.Initialize));
}

I will note, I did this with a regular textbox (without the EpiBinding obviously) and it beeps all day long. :rofl:

Have you tried putting it in a try-catch block? I’ve had trouble with other things gobbling up exceptions before

fox broadcasting quotes GIF by A Christmas Story Live

No exceptions. :sob:

		newTextBox.EpiBinding = "Origin." + col.ColumnName;

If you skip the binding do you get a beep?

Nope

If I make it a regular textbox I get a beep.

Stabbing in the dark, but have you tried MouseUpCustom?

I think the EpiTextBox inherits from Infragistics.Win.UltraWinEditors.UltraTextEditor

So I think the information here would apply:

https://www.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/46512/how-to-fully-enable-click-event-in-ultratexteditor

Maybe try a refresh of the textbox after it’s registered?

Ok, well now I’m beeping…

EditorWithText edit = newTextBox.Editor as EditorWithText;

//edit.TextBox.Visible = false;

edit.TextBox.Click += (s, e) =>
{
	Console.Beep(500, 125);
};

The EpiBinding is still not working though.

A static control on the form bound to the same does however.

Screw it. I cheated.

private void ShowValidation()
{
	int lastBottomPos = 0;
	foreach(DataColumn col in dsRate.Tables["Origin"].Columns)
	{
		TextBox newTextBox = new TextBox()
		{
			Width = thisForm.ClientSize.Width / 2,
			Height = 22,
			Left = 0,
			Top = lastBottomPos,
			Name = "txt" + col.ColumnName,
			Parent = thisForm,
		};

		lastBottomPos = newTextBox.Top + newTextBox.Height + 5;

		newTextBox.DataBindings.Add("Text", dsRate.Tables["Origin"], col.ColumnName);
		
		thisForm.Controls.Add(newTextBox);

		newTextBox.Click += (s, e) =>
		{
			Console.Beep(500, 125);
		};
	}
}
3 Likes

Anyway, I’ve got a life (somewhat) so if anyone knows the magic…

Need To Know Bau GIF by Paramount+

I’d think @hmwillett would but she’s probably forgotten all of the Classic UI stuff by now.

I cant remember, havent added a Custom Control since the E9 days.

This is how Epicor does it in a Nutshell

this.epiTextBoxC1 = new Ice.Lib.Framework.EpiTextBox();
this.epiTextBoxC1_12c68919_a18b_4255_9dea_21ffa10af39f = this.epiTextBoxC1;
System.Collections.Hashtable customControls = personalizeCustomizeManager.CustControlMan.CustomControlsHT;
customControls.Add("12c68919-a18b-4255-9dea-21ffa10af39f", this.epiTextBoxC1);
System.Collections.Hashtable controlsHT = personalizeCustomizeManager.ControlsHT;
controlsHT.Add("12c68919-a18b-4255-9dea-21ffa10af39f", this.epiTextBoxC1);
this.epiTextBoxC1.Name = "epiTextBoxC1";
this.epiTextBoxC1.EpiGuid = "12c68919-a18b-4255-9dea-21ffa10af39f";

// local2 being the Panel, GroupBox or FormName
local2.Controls.Add(this.epiTextBoxC1);

this.epiTextBoxC1.Top = 32;
this.epiTextBoxC1.Left = 341;
this.epiTextBoxC1.Width = 60;
this.epiTextBoxC1.Height = 20;
this.epiTextBoxC1.Text = "";
this.epiTextBoxC1.EpiBinding = "AbcCode.Company";

First:
If I had to guess you need to add the Control atleast to YourFormName.Controls.Add(...) or the GroupBox or Panel. Then when a Notify event fires Epicor needs to Enumerate all the Controls that have the EpiBinding and update them, and if they arent added to the Controls collection then it doesnt really know about them.

Second:
Or Perhaps register it with Personalization so Epicor can set the EpiTransaction on it.

System.Collections.Hashtable customControls = personalizeCustomizeManager.CustControlMan.CustomControlsHT;
customControls.Add("12c68919-a18b-4255-9dea-21ffa10af39f", this.epiTextBoxC1);

Somewhere behind the scenes then this runs, or try just setting EpiTransaction yourself.

if (iEpiCtrl.EpiTransaction == null)
{
	iEpiCtrl.EpiTransaction = this.oTransaction;
}
ctl.BindingContext = this.parentForm.BindingContext;

Post more code what is thisForm also that form must be somehow added, or pass in oTrans object to it and csm so you can register with it.

3 Likes

Thanks @hkeric.wci , I’ve tried most of that already, but I’ll try it again to make sure I didn’t miss anything.

2 Likes