Question Locked

VB.NET(Window based) - ListBox Data Population without using FormLoad event

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
i tried using form load event to populate the data in a listbox, Data successfully populated but as the code page form is a child form of another master form(main). the opening of child form starts with the load event of main form. In the main forms' 'Ok' button clicked event there is a login data validation occures and so a Try..Catch..finally...End try used. This try..catch throws argumentexception error. Please provide me any solution here

4 replies

by tony hopkinson

You might get away with moving the code to a later event, FormActivate for instance.

However to be safe, put a boolean in Form Load
initialised to false, check it in Activate, if false populate the listbox and set it to true.

However the order events fire in is not wholly reliable.
You would be better off switching things round so successful login populates the list box, or the sub form only gets loaded if there has been a successful login.

Further Info
http://www.knowdotnet.com/articles/eventfiringorder.html

by sujit.kumar.adhikari

Still required more help. When the login validation checked out and validated, I open the sub form within the Try..Catch block and this way the data populated in the listbox with throwing argument exception. Otherwise, if I place a reference to the main form open successfully, then the required data does not populated and there is no exception.

by tony hopkinson

that something else is going wrong

I'm assuming that the listbox populates from the database connection that you are logging into.

What line of code does the exception get thrown on if you step into the subform open routine.

This discussion is closed to new replies.