hello to everyone!

im new in C#
can somebody help me with my simple problem..

I have 2 forms.

First Form named Main_Menu and it has toolStrip named File,Add,Edit,Search

under File theres a sub menu Login.
_________________________________________________________________________________________

Second Form named Login

Login form was connected in SQL Server
_________________________________________________________________________________________

So here's i wanted to happen..
If i didn't Login the toolStrip named Add, Edit, and Search are disable or no function.

only the File sub menu Login are enable.

if i Login correctly the Add,Edit,Search now are Enable.

can somebody help me here..

Thanks in advance to all of you.

God bless

I think your best bet would be to use the Login form Modally.
Use FormInstance.ShowDialog() to show a modal instance of the form. Modal forms prevent the user from moving focus to other forms until they are closed. They also allow you to use the DialogResult property. Another useful behaviour of a modal form is that code execution on the calling form is paused until the modal form is closed, which allows you to show a form then process its results all in the same method:

Form2 frm = new Form2();
DialogResult result = frm.ShowDialog(); //show form modally and store its DialogResult
//code in this method will pause until frm has been closed

if(DialogResult == DialogResult.OK)
{
    //do something if form ended successfully
}

You can set the modal forms DialogResult by either assigning the property to relevant buttons on the form (eg have an OK button which sets DialogResult to OK) or manually in code (eg in the FormClosing event, evaluate something and set the DialogResult accordingly).

Using a modal form you can determine wether the user successfully authenticated themselves then enable/disable the relevant menus accordingly

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.