Performing a button click

I have a Shown event in my customization. In that Shown event I am trying to do a PerformClick() to click a button on the form. I want the button to click immediately after form is loaded. The problem is that the button click doesn’t happen. If I put a message box in the Shown event in front of the PerformClick() , the message box shows its message and the PerformClick() does the button click as expected. Take the message box out and no PerformClick(). Do any of you guys know what I can do to make this work as I intend? Here is my code. Not much here so you’d think it wouldn’t be that complicated.

private void SerialNumberAssignmentForm_Shown(object sender, EventArgs e)
{
//MessageBox.Show(“In Shown event”);
EpiButton btnSN = (EpiButton)csm.GetNativeControlReference(“c5d2179f-86c3-471d-bd2b-cab09c188b18”);
btnSN.PerformClick();
}

Hi Joel,

Hope you are doing well, it’s been a little while.

I would recommend the load event from the form events wizard in the customization mode. It is possible the form hasn’t loaded fully when you are trying to make this click action.

Doing this on part form, without the message box, works for me with the Epicor event.

Hey Zach, it has been a while. I tried it in the Load event as well with the same result. I even tried EpiDataView and it didn’t work either.

I will have to do some more testing on the particular form you’re using, since I just used a random form.

It still appears to be related to how the form is loading. Are you instantiating this form yourself or is it from a base Epicor action?

I am launching it with LaunchFormOptions. It is the Serial Number Assignment form.

I would use as well the Load event.
Do you pass a parameter to this form? If so, I would use EpiviewNotification to detect a currentRow present, then launch your button click. As mentioned by Zach, maybe the form is not yet ready for the click in the load event.

(mind you I did not test this… )

Pierre

Hi Pierre. How do I do that? Like this?

private void edvIM_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
if ((args.Row > -1))
{
EpiButton btnSN = (EpiButton)csm.GetNativeControlReference(“c5d2179f-86c3-471d-bd2b-cab09c188b18”);
btnSN.PerformClick();
}
}

sounds ok to me , :wink:

EpiDataView doesn’t work for me. It asks for a view when I am defining it. What view do I use? I tried using the view that is defined as the EpiBinding for the button I want to click but all it does is blank out one of my text boxes which I have pre-set in the Load event.