Here is the steps:
1) Added one Form with an Image, as Splashscreen.cs, and my main UI is Welcome.cs
2) In the Program.cs I modified the code like the following
[STAThread]
static void Main()
{
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
SplashScreen s = new SplashScreen();
s.Show();
Welcome welcome = new Welcome(s);
Application.Run(welcome);
}
3) And in the Welcome.cs, added one parameterized constructor, with SplashScreen as the Parameter
SplashScreen _s = null;
public Welcome(SplashScreen s)
{
InitializeComponent();
this._s = s;
}
4) And in the Form_Load() event I added code to close the splash screen if exists.
if (this._s != null) { this._s.Close(); }
5) Run the application, see the splash is coming and after that Main UI is coming
No comments:
Post a Comment