i got a problem.
i want to have 3 forms and both linked..i.e you can access all of them.the first to be a log in form, which when you have entered the correct user name and password,it lets you to the second form.the second and third are just forms to be filled in by the user.
kindly assist.

PS. concerning MDI parent and child classes.

Also, remember to add this.Hide(); after adatapost's code to hide the login form. Do the same for form2 if you don't want to use it when form3 is shown.

Thanks

in the Login for enter the code below when the lodin is successfil

new frmSeconForm().show();
this.Hide();//means the login form

then in the second form enter the below code where u need to open the third form:

new frmThirdForm().Show();
this.Close();//this means the frmSecondForm

hope this helped u?
thanxxxxxx

thank you all for your generous advice...they have all helped me a great deal.....but i have a new problem.
after i created the log in button and put the code that shows the second form,a problem came up while debugging it. the first form shows.wen you click the log in button, it brings the second button but it comes blank...all the buttons,labels and textboxes have disappeared.
what could be the problem
kindly assist

thank you all for your generous advice...they have all helped me a great deal.....but i have a new problem.
after i created the log in button and put the code that shows the second form,a problem came up while debugging it. the first form shows.wen you click the log in button, it brings the second button but it comes blank...all the buttons,labels and textboxes have disappeared.
what could be the problem
kindly assist

Sorry you confused me.

Lets Says you have three forms.

Loginfrm // Your Login form
Secfrm // Your Second Form
Thirdfrm // Your Third Form

Now What you are saying is that When you press login on Loginfrm, it goes to Secfrm but it comes up black?

Can you post some code?

Your code should look like this:

Secfrm frm2 = new Secfrm();
this.Hide();
rs.ShowDialog();

or alternatively

Secfrm frm2 = new Secfrm();
 if (rs.ShowDialog()== DialogResult.OK)
{
     MessageBox.Show("Yippe");
}

The Second Code will let you come back to Loginfrm. But I guess you would like to use that for Thirdfrm.

To go back to the previous form you would type the following:

this.DialogResult = DialogResult.OK

You can even customize your ending statement if they cancel out you by doing this:

Secfrm frm2 = new Secfrm();
 if (rs.ShowDialog()== DialogResult.OK)
{
     MessageBox.Show("Yippe");
}
else if (rs.ShowDialog()== DialogResult.Cancel)
{
     MessageBox.Show("Darn!!!");
}

Enjoy

I USE DRAG AND DROP
THIS IS A COPY OF THE CODES FOR THE FIRST FORM

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

namespace FAIRDEAL
{
    public partial class frmStores1 : Form
    {
        public frmStores1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox6_TextChanged(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            frmStores2 frm = new frmStores2();
            frm.Show();
            this.Hide();
        }
    }
}

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

To Finito, once i click on the log in button in the login form, it shows the second form but it comes blank....not black....i just gave the code.

ooooh am so sorry
wen you click the button av shown code for, it should take me to the log in form.which wen i enter the correct password,should get to me to the third form...the third form is password protected.
below is the code for the second form.

FORM2

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

namespace FAIRDEAL
{
    public partial class frmStores2 : Form
    {
        public frmStores2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            frmStores3 frm2 = new frmStores3();
            frm2.Show();
            this.Hide();
        }

        private void frmStores2_Load(object sender, EventArgs e)
        {
            string password = "pass123";
            if(textBox2.Text==password)
            {
                //password correct
                frmStores3 frm2 = new frmStores3();
                frm2.Show();
                this.Hide();
                

            }
        }
    }
}

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

string password = "pass123";
            if(textBox2.Text==password)
            {
                //password correct
                frmStores3 frm2 = new frmStores3();
                frm2.Show();
                this.Hide();

Should NOT be in Form Load

make it for a button.

i have done that but this is the error am getting

unable to copy file "obj\Debug\WindowApplication1.exe" to "bin\Debug\WindowApplication1.exe". the process is being used by another process.

yet this is the only process am running. p;acing the codes in the button event has helped.thaknk you again.kindly assist in this current problem

i have done that but this is the error am getting

unable to copy file "obj\Debug\WindowApplication1.exe" to "bin\Debug\WindowApplication1.exe". the process is being used by another process.

yet this is the only process am running. p;acing the codes in the button event has helped.thaknk you again.kindly assist in this current problem

HMM restart your computer.

still...am stlll getting the same error...but the first form runs well,its button brings forth the second form.the second form is the login form.i put the code in the button click code as you told me.the only problem is the log in button is not bringing the third form wen clicked.

You are still getting

unable to copy file "obj\Debug\WindowApplication1.exe" to "bin\Debug\WindowApplication1.exe". the process is being used by another process.

Error?

you have done something very wrong
I would suggest you start a new project if you haven't gone in too deep.

If it isn't possible can you post the code if the second form.

hey i got it...i googled the same error am getting and the problem had been solved...this is how it is solved

OK, I've found out how to sort it out. I ran a program which figured out which application had the file locked, and it turned out to be devenv.exe, i.e. Visual Studio itself. A bit more searching and I found a fix.

Create a pre-build action in your project by going to project properties (right-click on the project in the solution explorer, and select the Properties option), select the Build Events tab. Add this code:

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

This copies the file to a different name, and allows the build to continue successfully.

Hope that helps anyone else who's got this problem.

This article has been dead for over six months. Start a new discussion instead.