|
-
Jul 10th, 2004, 12:01 PM
#1
Thread Starter
Frenzied Member
After Form Load Event?
Is there a way to launch some code after the Form_Load method executes? I'm having some trouble in a MDI child. When I put the code I need to execute in the Form_Load, I get an OutOfMemoryException, but if I put this code under a button click in the child form, things work fine.
Thanks,
Mike
-
Jul 10th, 2004, 12:38 PM
#2
What about if you place the code into a Sub, which you call from the Form_Load?
Also, you could call another event like
VB Code:
Call Event_Name(Nothing, Me) 'for args, sender
-
Jul 10th, 2004, 01:02 PM
#3
Thread Starter
Frenzied Member
Thanks, mendhak, problem solved. Placing the code in a method called from Form_Load does not work, generating the same exception. But calling a public method after Form.Show to execute the code works fine.
Not sure why it works, but it works. Thanks!
Mike
-
Jul 10th, 2004, 01:30 PM
#4
What exactly are you doing that's not working in the Form_Load?
Maybe that'll give us a clue...
-
Jul 10th, 2004, 02:22 PM
#5
PowerPoster
Originally posted by Mike Hildner
Thanks, mendhak, problem solved. Placing the code in a method called from Form_Load does not work, generating the same exception. But calling a public method after Form.Show to execute the code works fine.
Not sure why it works, but it works. Thanks!
Mike
I agree with mendhak. I have no problem with calling from the load event of a child. It must be peculiar to what you are coding.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 10th, 2004, 02:26 PM
#6
Thread Starter
Frenzied Member
Populating a tree view with tables from a database. This is done through a web service. This is in C#, but should be interpretable to VB folks:
PHP Code:
PatriotWebService.PatriotClientWebService ws = new PatriotWebService.PatriotClientWebService();
dsTables = ws.GetUserTables();
// There's only one table in this data set, get it,
// and run through all the record in it, populating the
// tree view.
DataTableCollection dtc = dsTables.Tables;
DataTable dtUserTables = dtc[0];
foreach (DataRow row in dtUserTables.Rows)
{
//tvTableList.SelectedNode = 0;
//tvTableList.Nodes.Add(row["name"].ToString());
tvTableList.SelectedNode.Nodes.Add(row["name"].ToString());
}
tvTableList.ExpandAll();
Initially, I had the above code in Form_Load. I used this code in the MDI container:
PHP Code:
Tables t = new Tables(); // Tables is a Windows form
t.MdiParent = this;
t.Show();
When this code was in the constructor of the MDI parent, all went well. I moved it to execute when you click a button, and when that happened, I got an OutOfMemoryException.
-
Oct 19th, 2007, 04:57 AM
#7
New Member
Re: After Form Load Event?
A useful event for doing things once after form load is complete is the form's Shown event.
-
Oct 19th, 2007, 07:51 AM
#8
Junior Member
Re: After Form Load Event?
Probably an error because the controls you are trying to load haven't initialized yet ?
-
Oct 21st, 2007, 04:27 AM
#9
Re: After Form Load Event?
 Originally Posted by gplayer
A useful event for doing things once after form load is complete is the form's Shown event.
Given that this thread was created in 2004, before .NET 2.0 was released, Shown wasn't an option. It certainly would be nowadays, but back then we had to use the Activated event with a Boolean variable to indicate whether it's the first time or not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|