Control a Form from another Hidden Form in C#

10/10/2014 17:28 abdeen#1
I am working on a client that is sending a request to the server to login and if it's accepted the main window shall be hidden and user will start work on the form 2 named user_form ... and there are 3 buttons available for the users on the user_form ( logout - exit - hide )

I want control them all from the main window which is already hidden ,,,

Here is the code I am working with in main form ... but it's not working as I want.

PHP Code:
switch (client.LoginInfo.Limited)
{
    case 
true:
        
this.Hide();
        
User_Form LF = new User_Form(client);
        
LF.AdminControlIsVisible false;
        
DialogResult dr LF.ShowDialog(this);
        if (
dr == System.Windows.Forms.DialogResult.Cancel)
        {
            
//logout
        
}
        else if (
dr == System.Windows.Forms.DialogResult.OK)
        {
            if (
client != null)
            {
                
//hide
            
}
            else
            {
                
UpdateSystemMessage("No response from the server !!");
            }
            return;
        }
        break;
    case 
false:
        
User_Form LF = new User_Form(client);
        
LF.AdminControlIsVisible false;
        
DialogResult dr LF.ShowDialog(this);
        
this.Visible false;
        if (
dr == System.Windows.Forms.DialogResult.Cancel)
        {
            
//logout
        
}
        else if (
dr == System.Windows.Forms.DialogResult.OK)
        {
            if (
client != null)
            {
                
//hide
            
}
            else
            {
                
UpdateSystemMessage("No response from the server !!");
            }
            return;
        }
        break;

I mean that i have 2 forms ( form1, form2 ) i want to hide form1 and show form2 but i need to handle 3 buttons from form2 in the hidden form (form1) i mean ( form 1 control the 3 buttons which is in form2 ) and 2 of those buttons are getting the form1 is shown and close form 2 .. that's all .

Any solution ?
10/10/2014 22:14 Xio.#2
how about WCF?
10/10/2014 22:24 abdeen#3
Quote:
Originally Posted by Xio. View Post
how about WCF?
My problem is with windows forms application ...

Well thanks i fixed it and here is the answer :

Form1 Code :

PHP Code:
public void test()
    {
        
this.Hide();
        
Form2 frm2 = new Form2(this);
        
frm2.ShowDialog(this);
    } 
Form2 Code :

PHP Code:
private void button1_Click(object senderEventArgs e)
    {
        
frm.Test(this);
    }

    private 
Form1 MF;

    public 
User_Form(Form _FormClient.State client)
    {
        
this.frm _Form;
        
InitializeComponent();
    } 
Form1 Code :

PHP Code:
public void Test(Form test)
    {
        
test.Hide();
        
this.Show();
    }