Just studied C # and ran into a similar situation. but found a solution that I think can help. Perhaps you understood this a long time ago. it will be from the start of a new project, but you can use it in any.
1) Start a new project.
2) go to Project, then New Windows form, then select Windows Form and name it Splash.
3) set the size, background, text, etc. Optional.
4) In the properties of the Splash.cs form, set the starting position: CenterScreen and TopMost: true
5) add form1 "using System.Threading;"
6) Form1 in the class add "Splash splashscreen = new Splash ();"
7) form1 add "splashscreen.Show ();" and "Application.DoEvents ();"
8) form1 In the section Events >> Focus >> Activated add "Thread.Sleep (4000); splashscreen.Close ();"
9) add Splash.cs to "Public Splash" add "this.BackColor = Color.Aqua;" / any color can be used
10) This is the code for Form1.cs
public partial class Form1 : Form { Splash splashscreen = new Splash(); public Form1() { InitializeComponent(); splashscreen.Show(); Application.DoEvents(); } private void Form1_Activated(object sender, EventArgs e) { Thread.Sleep(4000); splashscreen.Close(); } }
11) this is the code for Splash.cs
public partial class Splash : Form { public Splash() { InitializeComponent(); this.BackColor = Color.Aqua; } }
12) I found that if you do not do anything in the splash screen, the screen will not remain top for the time that you need to activate the first form. The thread counter will disappear after x seconds, so your program is working fine.
John B May 20 '18 at 22:42 2018-05-20 22:42
source share