klincecum
(Kevin Lincecum)
April 25, 2024, 6:15pm
1
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));
}
klincecum
(Kevin Lincecum)
April 25, 2024, 6:18pm
2
I will note, I did this with a regular textbox (without the EpiBinding obviously) and it beeps all day long.
Have you tried putting it in a try-catch block? I’ve had trouble with other things gobbling up exceptions before
newTextBox.EpiBinding = "Origin." + col.ColumnName;
If you skip the binding do you get a beep?
klincecum
(Kevin Lincecum)
April 25, 2024, 6:52pm
8
If I make it a regular textbox I get a beep.
klincecum:
EpiTextBox
Stabbing in the dark, but have you tried MouseUpCustom?
jwphillips
(Jonathan Phillips)
April 25, 2024, 7:07pm
11
Now the revision combo is showing but not the other boxes. So I know there is data in the response.
edv_BOMPartSummary.Row = 0;
txtPartDescription.Refresh();
cboRevisions.Refresh();
txtUnitPrice.Refresh();
txtCustLeadTime.Refresh();
[Capture]
Maybe try a refresh of the textbox after it’s registered?
klincecum
(Kevin Lincecum)
April 25, 2024, 7:21pm
12
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.
klincecum
(Kevin Lincecum)
April 25, 2024, 7:39pm
13
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
klincecum
(Kevin Lincecum)
April 25, 2024, 7:42pm
14
Anyway, I’ve got a life (somewhat) so if anyone knows the magic…
Randy
(Randy Stulce)
April 25, 2024, 8:33pm
15
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
klincecum
(Kevin Lincecum)
April 26, 2024, 4:40pm
17
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