Click here to Skip to main content
15,885,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 3 forms like form1,form2,form3
each form will load one by one every 10 seconds .

Please help me out.

What I have tried:

Program.cs
.........................

static class Program
{
public static RadForm1 RadForm1 = null;
public static RadForm2 RadForm2 = null;
public static RadForm3 RadForm3 = null;
public static int Flag = 0;
/// <summary>
///
[STAThread]
static void Main()
{

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Thread splashThread = new Thread(new ThreadStart(
delegate
{
RadForm1 = new RadForm1();
RadForm1.Size = new System.Drawing.Size(1365, 739);
Application.Run(RadForm1);
}
));

splashThread.SetApartmentState(ApartmentState.STA);
splashThread.Start();


RadForm2 = new RadForm2();
RadForm2.Size = Screen.PrimaryScreen.WorkingArea.Size;
RadForm2.Load += new EventHandler(RadForm1_Load);
Application.Run(RadForm2);

RadForm3 = new RadForm3();
RadForm3.Size = Screen.PrimaryScreen.WorkingArea.Size;
RadForm3.Load += new EventHandler(RadForm2_Load);
Application.Run(RadForm3);

}
static void RadForm1_Load(object sender, EventArgs e)
{
if (RadForm1 == null)
{
return;
}
RadForm1.Invoke(new Action(RadForm1.Close));
RadForm1.Dispose();
RadForm1 = null;
}
static void RadForm2_Load(object sender, EventArgs e)
{
if (RadForm2 == null)
{
return;
}
RadForm2.Invoke(new Action(RadForm2.Close));
RadForm2.Dispose();
RadForm2 = null;
}
}

and in second form................

public RadForm2()
{
InitializeComponent();
Thread.Sleep(5000);
this.StartPosition = FormStartPosition.CenterScreen;
}
Posted
Updated 17-Feb-18 0:37am
v3
Comments
BillWoodruff 16-Feb-18 21:19pm    
If you are using Telerik, why not use their support ?

You need to describe what you want in more detail. Does the user interact with this series of Forms shown one by one: is any data collected and stored, or passed on to the next Form ?
BillWoodruff 17-Feb-18 1:27am    
"I want All the Forms sliding( like image slide show)" Why do you think you should use multiple Forms for this ? Why not use a single Form controlling a series of Panels ?
#realJSOP 17-Feb-18 7:55am    
He deleted his comments to my answer, and I was gonna say this. Using multiple forms is not the correct approach.
sharat naik 17-Feb-18 6:31am    
Because i am making project on textile, in that more than 30 forms are available and each form having all equipment details and production details. these details are displayed in 50" monitor.
if i used panels it is more difficult configure all different screens and i required full screen display..
thank you
please suggest me
sharat naik 17-Feb-18 6:39am    
i have updated code , in that it will go to 1st and 2nd form, how to go2 3rd form

Well, assuming you're reasonably skilled at winforms development, here's a simple example that I whipped up in about 10 minutes. The first for is displayed for 10 seconds, and then closes, upon which time the 2nd form opens automagically.

Step 1 - Create a new winforms app (it will already have "Form1"). I added an ok and cancel buttons to the form. but you don't have to.

Step 2 - Add a new form ("Form2").

Step 3 - In program.cs, change the main function to look like this:

C#
[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Form1 f1 = new Form1();
    Application.Run(f1);
    if (f1.DialogResult== DialogResult.OK)
    {
        Form2 f2 = new Form2();
        Application.Run(f2);
        f2.Activate();
                
    }
}


Step 4 - This is your Form1 code

C#
public partial class Form1:Form
{
    int dismiss = 10000;
    int elapsed = 0;
    Timer timer;
    public Form1()
    {
        InitializeComponent();
        timer = new Timer(){ Interval = 50, Enabled=true };
        timer.Tick += timer_Tick;
    }

    void timer_Tick(object sender,EventArgs e)
    {
        elapsed += timer.Interval;
        if (elapsed >= dismiss)
        {
            button1.PerformClick();
        }
    }

    private void button2_Click(object sender,EventArgs e)
    {
        DialogResult = DialogResult.Cancel;
        this.Close();
    }

    private void button1_Click(object sender,EventArgs e)
    {
        DialogResult = DialogResult.OK;
        this.Close();
    }

    private void Form1_FormClosing(object sender,FormClosingEventArgs e)
    {
        timer.Enabled = false;
        timer.Dispose();

    }
}


The timer might be too granular, but timer events are the lowest priority events in windows, and they are not guaranteed to be handled on a busy system. I would recommend using another technique for this, but for the purposes of example, it's suitable.
 
Share this answer
 
v4
Comments
BillWoodruff 16-Feb-18 21:23pm    
far out man ! I doubt the OP here (apparently using Telerik) has a clear idea of what they want.
BillWoodruff 17-Feb-18 8:11am    
+5 You gave the OP what he asked for !
You should be able to moify this code to do what you want:

Multiple Subsequent "Main" Forms in C# Apps[^]
 
Share this answer
 
Comments
sharat naik 16-Feb-18 6:36am    
i tried but it wont go2 second page,
i want form1 will load for 10sec and after 10sec form1 close and form2 will load.
Every 10seconds each page loading..
#realJSOP 16-Feb-18 7:13am    
Then your code is wrong. We can't help you if you don't show us your code.
sharat naik 17-Feb-18 6:40am    
i have updated code , in that it will go to 1st and 2nd form, how to go2 3rd form

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900