I have added a “Subcontracted” checkbox to “Sales Order Entry” on the “Release/Detail” tab. I want it be disabled if “Make Direct” is checked, similar to “Buy To Order”. Also, if “Subcontract” is checked and “Make Direct” selected, “Subcontracted” will be unchecked before being disabled. The event Wizard does not allow adding event to existing controls. Is there a way I can do this?
Yes you can, but first, most of the time you want to monitor the events on the underlying dataviews.
You usually only go to the form/control events if you need to work around something.
Native control reference:
public class Script
{
EpiButton btnSearch;
public void InitializeCustomCode()
{
btnSearch = (EpiButton)csm.GetNativeControlReference("3b06b8f2-a9d0-44d0-9aa1-4db6ddc60c77"); //Guid of native control
btnSearch.Click += new System.EventHandler(btnSearch_Click);
}
public void DestroyCustomCode()
{
btnSearch.Click -= new System.EventHandler(btnSearch_Click);
}
private void btnSearch_Click(object sender, System.EventArgs args)
{
MessageBox.Show("Woot!");
}
}
Monitoring a dataview
private void UD01_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
switch (args.Column.ColumnName)
{
case "CheckBox01":
MessageBox.Show(args.Row[args.Column.ColumnName].ToString());
break;
}
}
You can also just hide the native control, and put a custom control that has the same EpiBinding. Then the wizard will let you do things to that custom control. It’s probably not as efficient, but it is easier to do in some cases (I’ve done that on more than one screen)
1 Like