Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there,

I have three forms:
frmMain, frmLogin and frmPanel.


When I run my program it shows frmMain which is an MDI container, and on load I open Login form as child.

Now when I login and information is correct I need to enable buttons on my toolstrip1 which are disabled on load.

What I've tried is to make a function inside frmMain

C#
void functionOnForm1()
{
    this.toolStripButton7.Enabled = true;
}

then on login form after password is OK I call this function:
C#
((frmMain)this.MdiParent).functionOnForm1();

but I get the following error:
'Project1.frmMain.functionOnForm1()' is inaccessible due to its protection level (CS0122).

This is frmMain:
C#
public partial class frmMain  : Form
{
    public frmMain()
    {
        InitializeComponent();
    }

    void functionOnForm1()
    {
        MessageBox.Show("ddd");
    }
}

Does anybody know how to change property or labels from child on parent?
Posted
Updated 2-Apr-10 8:18am
v2

You have two choices.

Either make the method in frmMain public, or raise an event in frmLogin along the lines of this[^].

In a MDI application I normally prefer the first (easier) approach.
 
Share this answer
 
Please place your code in the code block tags. It makes it much easier for us to read your code.

[Added] I've edited the question on behalf of the OP, DaveyM69. [/Added]
 
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