Firing a button event after form has loaded

I've got a login screen which if ran with certain parameters logs the user into the product automatically.

The problem I have is I try to simulate the pressing of the btnOK to make the product login but I've put this at the end of the load. This results in the screen not being fully drawn before the login starts so it stays half drawn for a few seconds and looks terrible.

Ideas appreciated.



Answer this question

Firing a button event after form has loaded

  • durga prasad p.v.

    Assuming VS 2005 you could try the following (I haven't tried these):

    A. Insert the statement "Application.DoEvents" just prior to you calling the btnOK event. This should let all queued windows messages execute and then return to your code to do the btnOK event, which hopefully will make the form more complete.

    or

    B. Run the btnOK event from the Form.Shown or Form.Activate event instead of from the Form.Load event. Of course if you use Form.Activate you will have to set a boolean variable to make sure this gets executed only once from this event as it will fire each time the form window is selected by the user.

    That's all I got for you. Good luck.


  • Lost Shadow

    only this way works :

    Button1.PerformClick()

  • rileytaylor

    Cranker,

    What you need is to invoke Login method, but not to fire button_Click event. Do not put any proceeding/logical operations in your event handlers, invoke methods implementing desired functionality instead.

  • Firing a button event after form has loaded