Creation of an Event Handler for Key1

I need to gain control of my customization after the txtKeyField field value has changed. Being that native controls event handlers and not available like custom controls, I need the solution where I can gain that access and make the appropriate processes when that field value has changed and lost focus.

I have added a duplicate field definition using the GUID like …

public EpiTextBox txtDieNum;
txtDieNum = (EpiTextBox)csm.GetNativeControlReference(“e5d73cb9-1d94-45ce-85be-db4c85fe3264”);

I’m assuming the GUID value used in the above statement is of the txtKeyField listed in the properties of that native control. Then, when the value of the txtKeyField changes, I could catch it via the txtDieNum. Or … should I just completely hid all of the native key field controls and use all custom controls and just pass my values to the KeyField values when needed?

Hey Kent, I think your first idea would probably be easier than completely remaking all the native controls. Another option would be to create a new text box using the Toolbox, bind it to the same field as the native control (txtKeyField), and then hide it. Then you will be able to use the event wizard to set up an afterFieldChange event easily. I don’t think the lost focus event would work doing it this way unfortunately.

I appreciate the reply. So, create a new custom control, txtDieNum, and bind that to the UD04.Key1 ? I didn’t know you could have multiple custom fields bound to the same UD field (or column). Then hide the txtKeyValue native control?

I’m I understanding that correctly?

Pretty close, not my greatest explanation ;). You’ll hide the custom control you created, but still tie an event to it (ValueChanged should work). The native control will stay visible/usable, that way you keep all the functionality tied to it.

You can bind as many text boxes as you want to a UD field too.

The Form Event Wizard could be another option. You should be able to set an AfterFieldChange on the field the controls are bound too, rather than the control itself.

You will likely have to hide the control via code. For whatever reason, once a control is bound to a field, it doesn’t like to stay disabled/invisible by just changing it in the properties window.

You can create event handlers for native controls:

1 Like

I think the Form Event Wizard using the AfterFieldChange looks like it will work for me. I was able to bring up a message box when tabbing off of txtKeyValue field. Thank you.

1 Like

Calvin, thanks for the suggestion but I did try that one. I was very detailed with it but when compiling the code, it didn’t even recognize the Click event. So … I’m sure I did something wrong. I just couldn’t get it to work.