Victor Charles
asked on
Help with activating Forms and button click events using vb.net
Hi,
Using a button click event, how do you activate a Form Load event of another Form?
Thanks,
Victor
Using a button click event, how do you activate a Form Load event of another Form?
Thanks,
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Fernando,
I only need one button click event. When I click on the search button from Form1, I am displaying the results in Form2 because the code is activated in Form Load event of Form2 to display the data, problem is when I close Form2 by using Form2.visible = False and press the search button again on Form1 the code in Form2 Load event does not execute.
I tried your code but the code in Form2 Load event still does not execute when I press the search button in Form1 after closing Form2.
Thanks,
Victor
I only need one button click event. When I click on the search button from Form1, I am displaying the results in Form2 because the code is activated in Form Load event of Form2 to display the data, problem is when I close Form2 by using Form2.visible = False and press the search button again on Form1 the code in Form2 Load event does not execute.
I tried your code but the code in Form2 Load event still does not execute when I press the search button in Form1 after closing Form2.
Thanks,
Victor
ASKER
Hi,
It works with Form2.close.
Thanks,
Victor
It works with Form2.close.
Thanks,
Victor
ASKER
Thank You.
Hi Victor;
To your previous statement, "I am displaying the results in Form2 because the code is activated in Form Load event of Form2 to display the data, problem is when I close Form2 by using Form2.visible = False and press the search button again on Form1 the code in Form2 Load event does not execute.", The Form_Load event only happens once in the life cycle that is just after the Form is create and initialized. Therefore if you were to make the Form invisible by changing its Visible property to False then you will not be able to see the Form but the Form has NOT been closed, closed is having the Form disposed of.
To your previous statement, "I am displaying the results in Form2 because the code is activated in Form Load event of Form2 to display the data, problem is when I close Form2 by using Form2.visible = False and press the search button again on Form1 the code in Form2 Load event does not execute.", The Form_Load event only happens once in the life cycle that is just after the Form is create and initialized. Therefore if you were to make the Form invisible by changing its Visible property to False then you will not be able to see the Form but the Form has NOT been closed, closed is having the Form disposed of.
ASKER
Hi Fernando,
I understand.
Thanks,
Victor
I understand.
Thanks,
Victor
To your question, "Using a button click event, how do you activate a Form Load event of another Form?", I am assuming that the other form is already created and you have an instance of the other form. I want to say that this is not the Best Practices to call another forms Load event. The below code is the answer to the question.
Open in new window