This is a short follow-up to the last show with a few examples of where you can easily make use of the Load vs. Shown events.
The three things that are good uses are for splash screens in the Load event, and Buy Now or License screens in the Shown event.
There are two very simple sample applications that demonstrate the differences. Here's the code for the two forms:
1:namespace DotNetPreacher_001_Shown_A
2:{ 3:public partial class Form1 : Form
4: { 5:public Form1()
6: { 7: InitializeComponent();
8: }
9:
10:private void Form1_Load(object sender, EventArgs e)
11: { 12: // Here we create the splash form in the Load event. Notice how the main form doesn't show when you run it.
13: SplashScreen splash = new SplashScreen();
14: splash.ShowDialog();
15: // See the Shown event for another hint on getting rid of the splash screen.
16: // Check the other sample app for an example of showing the license form in the Shown event.
17: }
18:
19:private void Form1_Shown(object sender, EventArgs e)
20: { 21: // This might be a good place to get rid of your splash screen. In that case, you may wish to move the
22: // declaration to a global scope and then create it in the load event.
23: // This would be normal as you don't generally have any way to close a splash screen.
24: // i.e. The "splash" above would have it's form border style set to none.
25: // e.g. splash.FormBorderStyle = FormBorderStyle.None; // But probably done in the designer...
26: }
27: }
28:}
29:
30:
31:namespace DotNetPreacher_001_Shown_B
32:{ 33:public partial class Form1 : Form
34: { 35:public Form1()
36: { 37: InitializeComponent();
38: }
39:
40:private void Form1_Shown(object sender, EventArgs e)
41: { 42: // Here we load the license form in the Shown event when the main form is shown.
43: // Notice here how you can see the main form behind the license form.
44: LicenseForm lic = new LicenseForm();
45: lic.ShowDialog();
46: }
47: }
48:}
Pretty simple stuff. The effect is what you're after though.