Form Applications: How to Redirect The User Form To Login Form in c#?Form Application

Discussion in 'C#' started by umarfarooq21, Jul 26, 2011.

  1. umarfarooq21

    umarfarooq21 New Member

    Joined:
    Jul 26, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am newbie to programming and using window form application i have 2 forms Form1 and Form2, i wanted to open old form application i.e Form1 here is my code of Form2

    Code:
    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 SQL1
    {
        public partial class Form2 : Form
        {
    
            public Form2()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                this.Visible = false;
                ________________??
    
            }
        }
    }
    i simply wanted if user click on signout button which is on Form2 then Form1 window Application open can Any one help me its my assignment please help me......!
     
  2. 7900142

    7900142 New Member

    Joined:
    Jan 12, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Free lance software developer, an instructor and a
    Location:
    Philippines
    Re: Form Applications: How to Redirect The User Form To Login Form in c#?Form Applica

    Hey Dude,
    This is a hack. Maybe there are other C# developers that may comment to this solution of mine. Anyway, this will work as prescribed in your requirements.

    @ the First Form
    PHP:
    namespace WindowsFormsApplication1
    {
        public 
    partial class Form1 Form
        
    {
            public 
    Form1()
            {
                
    InitializeComponent();
            }

            private 
    void button1_Click(object senderEventArgs e)
            {
                
    //instantiate an object from form2,pass an object to form2
                //passing the same reference of the current form
                
    Form2 f2 = new Form2(this);
                
    //hide current form
                
    this.Hide();
                
    f2.Show();
            }
        }
    }

    @ FORM 2
    PHP:
    namespace WindowsFormsApplication1
    {
        public 
    partial class Form2 Form
        
    {
            
    //object fro form1
            
    Form1 f1;
            public 
    Form2(Form1 cf)
            {
                
    InitializeComponent();
                
    //set a new instance of form1
                
    f1 cf;
            }

            private 
    void Form2_FormClosed(object senderFormClosedEventArgs e)
            {
                
    //on closing show the new object
                
    f1.Show();
            }

            private 
    void button1_Click(object senderEventArgs e)
            {
                
    this.Close();
            }

        }
    }

     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice