Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
How can we display splash screen with progress bar between two form until second form loaded in c# .net windows application?
 
How is it possible?
 
Help Me.
 
Thanks in Advance.
 
Ankit Agarwal
Software Engineer
Posted 24-Dec-12 7:45am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I designed an easy solution. I have not used Asynhcronous model. If it is needed you can use BackgroundWorker class.
 
My code is below.
 
public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();
       }
 
       private void btnOpen_Click(object sender, EventArgs e)
       {
           Form2 frm = new Form2();
       }
   }
 
Form2.cs
 
public partial class Form2 : Form
    {
        Timer tmr;
        ProgressBar p;
        frmSplash f;
        public Form2()
        {
            InitializeComponent();
            tmr = new Timer();
            tmr.Interval = 1000;
            tmr.Tick += new EventHandler(tmr_Tick);
            tmr.Start();
            p = new ProgressBar();
            p.Height = 30;
            p.Width = 320;
            f = new frmSplash(p);
            f.Show();
        }
 
        void tmr_Tick(object sender, EventArgs e)
        {
            p.Value += 20;
            if (p.Value == 100)
            {
                tmr.Stop();
                Application.DoEvents();
                f.Hide();
                this.Show();
 

            }
        }
    }
 
And I added a WinForm named frmSplash and put a flowLayoutPanel on it. Code is below.
 
public partial class frmSplash : Form
    {
        public frmSplash(ProgressBar prg)
        {
            InitializeComponent();
            flowLayoutPanel1.Controls.Add(prg);
        }
    }
 
Run Form1 and click button. First splash form will be opened after progressbar is filled it will be hide and Form2 will be displayed.
 
Regards,
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,189
1 Sergey Alexandrovich Kryukov 5,666
2 CPallini 4,810
3 George Jonsson 3,429
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100