Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to open a form when press OK button in log in form ?
I am making a simple project of two forms
first form contains user name and password with two buttons if user legal OK button open next form
and close log in form
second form contains buttons for data base
Posted
Updated 24-Dec-11 14:46pm
v2

Show your first form as modal window. Your application will wait to close form and then you can show next form. Same material: http://msdn.microsoft.com/en-us/library/aa984358(v=VS.71).aspx[^]
 
Share this answer
 
Comments
ZezoElhelw 24-Dec-11 21:06pm    
I tried but i want to close first form
on buttonclick event

frm_new objform=new frm_new();
objform.showdailog();
 
Share this answer
 
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string Username = "ezz";
        string Password = "zezo";

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != null && textBox1.Text == Username)
            {
                if (textBox2.Text != null && textBox2.Text == Password)
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show("wrong password");
                }
            }
        }

        private void button2_Click(object sender, System.EventArgs e)
        {
            Application.Exit();
        }

    }
}






ADD THIS TO MAIN

Application.Run(new Form1());
Application.Run(new Form2());
 
Share this answer
 
v2

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