300x250 AD TOP

helooo
Tagged under:

Redirection in Winforms

Description:-

Redirection is nothing but control transfers from one form to another form,
Below code explains how redirection takes place in win-forms application
Form1.cs:
---------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace transfering
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

      private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Form2 f2 = new Form2();         //this is second form object creation
            f2.Show();                                 //showing the second form
            this.Hide();                               //hiding the Currunt form (Form1)
        }
    }
}

Form2.cs:
----------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace transfering
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Form1 f1 = new Form1();         //creating object for Form1
            f1.Show();                                 //showing Form1
            this.Hide();                               //hiding Current form(Form2)
        }
    }
}

Screens:
-------
         Fig:Form1






         Fig:Form2




Click below Icon for full project download