Some more code from the 2 forms:
frmStrikeTourna ment:
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
namespace StrikeTournamen t
{
public class frmStrikeTourna ment : System.Windows. Forms.Form
{
private System.Windows. Forms.MainMenu mnuMain;
private System.Windows. Forms.MenuItem mnuSystem;
private System.Windows. Forms.MenuItem mnuSystemExit;
private System.Windows. Forms.MenuItem mnuSystemSelect System;
private System.Windows. Forms.MenuItem mnuSystemSepera tor1;
private System.Windows. Forms.MenuItem mnuSystemAdminL ogin;
private System.Windows. Forms.MenuItem mnuSystemSetup;
private System.Windows. Forms.MenuItem mnuSystemSepera tor2;
private System.Windows. Forms.MenuItem mnuHelp;
private System.Windows. Forms.MenuItem mnuHelpHelp;
private System.Windows. Forms.MenuItem mnuHelpAbout;
private System.Windows. Forms.MenuItem mnuSystemSetupT ournament;
private System.Windows. Forms.MenuItem mnuSystemSetupC ategory;
private System.Windows. Forms.MenuItem mnuSystemSetupR ow;
private System.Componen tModel.Containe r components = null;
public frmStrikeTourna ment()
{
InitializeCompo nent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeCompo nent()
{
System.Resource s.ResourceManag er resources = new
System.Resource s.ResourceManag er(typeof(frmSt rikeTournament) );
this.mnuMain = new System.Windows. Forms.MainMenu( );
this.mnuSystem = new System.Windows. Forms.MenuItem( );
this.mnuSystemS electSystem = new System.Windows. Forms.MenuItem( );
this.mnuSystemS eperator1 = new System.Windows. Forms.MenuItem( );
this.mnuSystemA dminLogin = new System.Windows. Forms.MenuItem( );
this.mnuSystemS etup = new System.Windows. Forms.MenuItem( );
this.mnuSystemS etupTournament = new System.Windows. Forms.MenuItem( );
this.mnuSystemS etupCategory = new System.Windows. Forms.MenuItem( );
this.mnuSystemS etupRow = new System.Windows. Forms.MenuItem( );
this.mnuSystemS eperator2 = new System.Windows. Forms.MenuItem( );
this.mnuSystemE xit = new System.Windows. Forms.MenuItem( );
this.mnuHelp = new System.Windows. Forms.MenuItem( );
this.mnuHelpHel p = new System.Windows. Forms.MenuItem( );
this.mnuHelpAbo ut = new System.Windows. Forms.MenuItem( );
//
// mnuMain
//
this.mnuMain.Me nuItems.AddRang e(new System.Windows. Forms.MenuItem[] {
this.mnuSystem,
this.mnuHelp});
//
// mnuSystem
//
this.mnuSystem. Index = 0;
this.mnuSystem. MenuItems.AddRa nge(new System.Windows. Forms.MenuItem[] {
this.mnuSystemS electSystem,
this.mnuSystemS eperator1,
this.mnuSystemA dminLogin,
this.mnuSystemS etup,
this.mnuSystemS eperator2,
this.mnuSystemE xit});
this.mnuSystem. Text = "&System";
//
// mnuSystemSelect System
//
this.mnuSystemS electSystem.Ena bled = false;
this.mnuSystemS electSystem.Ind ex = 0;
this.mnuSystemS electSystem.Tex t = "&Vælg system";
this.mnuSystemS electSystem.Cli ck += new
System.EventHan dler(this.mnuSy stemSelectSyste m_Click);
//
// mnuSystemSepera tor1
//
this.mnuSystemS eperator1.Index = 1;
this.mnuSystemS eperator1.Text = "-";
//
// mnuSystemAdminL ogin
//
this.mnuSystemA dminLogin.Index = 2;
this.mnuSystemA dminLogin.Short cut = System.Windows. Forms.Shortcut. CtrlA;
this.mnuSystemA dminLogin.Text = "Administra tor &login";
this.mnuSystemA dminLogin.Click += new
System.EventHan dler(this.mnuSy stemAdminLogin_ Click);
//
// mnuSystemSetup
//
this.mnuSystemS etup.Enabled = false;
this.mnuSystemS etup.Index = 3;
this.mnuSystemS etup.MenuItems. AddRange(new
System.Windows. Forms.MenuItem[] {
this.mnuSystemS etupTournament,
this.mnuSystemS etupCategory,
this.mnuSystemS etupRow});
this.mnuSystemS etup.Text = "&Opsætnin g af stævne";
//
// mnuSystemSetupT ournament
//
this.mnuSystemS etupTournament. Index = 0;
this.mnuSystemS etupTournament. Text = "&Stævne";
//
// mnuSystemSetupC ategory
//
this.mnuSystemS etupCategory.In dex = 1;
this.mnuSystemS etupCategory.Te xt = "&Kategori" ;
//
// mnuSystemSetupR ow
//
this.mnuSystemS etupRow.Index = 2;
this.mnuSystemS etupRow.Text = "&Række";
//
// mnuSystemSepera tor2
//
this.mnuSystemS eperator2.Index = 4;
this.mnuSystemS eperator2.Text = "-";
//
// mnuSystemExit
//
this.mnuSystemE xit.Index = 5;
this.mnuSystemE xit.Shortcut = System.Windows. Forms.Shortcut. CtrlX;
this.mnuSystemE xit.Text = "&Afslut";
this.mnuSystemE xit.Click += new
System.EventHan dler(this.mnuSy stemExit_Click) ;
//
// mnuHelp
//
this.mnuHelp.In dex = 1;
this.mnuHelp.Me nuItems.AddRang e(new System.Windows. Forms.MenuItem[] {
this.mnuHelpHel p,
this.mnuHelpAbo ut});
this.mnuHelp.Te xt = "&Hjælp";
//
// mnuHelpHelp
//
this.mnuHelpHel p.Index = 0;
this.mnuHelpHel p.Shortcut = System.Windows. Forms.Shortcut. F1;
this.mnuHelpHel p.Text = "Strike Tournament .NET hjælp";
//
// mnuHelpAbout
//
this.mnuHelpAbo ut.Index = 1;
this.mnuHelpAbo ut.Text = "&Om Strike Tournament .NET";
//
// frmStrikeTourna ment
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(736, 449);
this.Icon = ((System.Drawin g.Icon)(resourc es.GetObject("$ this.Icon")));
this.IsMdiConta iner = true;
this.Menu = this.mnuMain;
this.Name = "frmStrikeTourn ament";
this.Text = "Strike Tournament .NET";
this.WindowStat e = System.Windows. Forms.FormWindo wState.Maximize d;
this.Load += new System.EventHan dler(this.frmSt rikeTournament_ Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run (new frmStrikeTourna ment());
}
private void mnuSystemExit_C lick(object sender, System.EventArg s e)
{
this.Dispose();
}
private void frmStrikeTourna ment_Load(objec t sender, System.EventArg s e)
{
// Calling from here works
fine...
EnableMenuOnLog in();
}
private void mnuSystemAdminL ogin_Click(obje ct sender, System.EventArg s e)
{
frmLogin newMDIChild = new frmLogin();
newMDIChild.Mdi Parent = this;
newMDIChild.Sho w();
}
private void mnuSystemSelect System_Click(ob ject sender, System.EventArg s e)
{
}
public void EnableMenuOnLog in()
{
// public, but doesn't seem
to be visible for the other form
this.mnuSystemS electSystem.Ena bled = true;
}
}
}
frmLogin:
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
namespace StrikeTournamen t
{
public class frmLogin : System.Windows. Forms.Form
{
private System.Windows. Forms.GroupBox gbxLogin;
private System.Windows. Forms.Label lblUserId;
private System.Windows. Forms.Label lblPassword;
private System.Windows. Forms.Button btnLogin;
private System.Windows. Forms.TextBox txtUserId;
private System.Windows. Forms.TextBox txtPassword;
private System.Componen tModel.Containe r components = null;
public frmLogin()
{
InitializeCompo nent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeCompo nent()
{
System.Resource s.ResourceManag er resources = new
System.Resource s.ResourceManag er(typeof(frmLo gin));
this.gbxLogin = new System.Windows. Forms.GroupBox( );
this.txtPasswor d = new System.Windows. Forms.TextBox() ;
this.txtUserId = new System.Windows. Forms.TextBox() ;
this.btnLogin = new System.Windows. Forms.Button();
this.lblPasswor d = new System.Windows. Forms.Label();
this.lblUserId = new System.Windows. Forms.Label();
this.gbxLogin.S uspendLayout();
this.SuspendLay out();
//
// gbxLogin
//
this.gbxLogin.C ontrols.Add(thi s.txtPassword);
this.gbxLogin.C ontrols.Add(thi s.txtUserId);
this.gbxLogin.C ontrols.Add(thi s.btnLogin);
this.gbxLogin.C ontrols.Add(thi s.lblPassword);
this.gbxLogin.C ontrols.Add(thi s.lblUserId);
this.gbxLogin.L ocation = new System.Drawing. Point(8, 8);
this.gbxLogin.N ame = "gbxLogin";
this.gbxLogin.S ize = new System.Drawing. Size(288, 96);
this.gbxLogin.T abIndex = 0;
this.gbxLogin.T abStop = false;
this.gbxLogin.T ext = "Administra tor login";
//
// txtPassword
//
this.txtPasswor d.Location = new System.Drawing. Point(144, 40);
this.txtPasswor d.Name = "txtPasswor d";
this.txtPasswor d.Size = new System.Drawing. Size(136, 20);
this.txtPasswor d.TabIndex = 4;
this.txtPasswor d.Text = "";
//
// txtUserId
//
this.txtUserId. Location = new System.Drawing. Point(144, 16);
this.txtUserId. Name = "txtUserId" ;
this.txtUserId. Size = new System.Drawing. Size(136, 20);
this.txtUserId. TabIndex = 3;
this.txtUserId. Text = "";
//
// btnLogin
//
this.btnLogin.L ocation = new System.Drawing. Point(208, 64);
this.btnLogin.N ame = "btnLogin";
this.btnLogin.S ize = new System.Drawing. Size(72, 24);
this.btnLogin.T abIndex = 2;
this.btnLogin.T ext = "&Login";
this.btnLogin.C lick += new System.EventHan dler(this.btnLo gin_Click);
//
// lblPassword
//
this.lblPasswor d.Location = new System.Drawing. Point(8, 44);
this.lblPasswor d.Name = "lblPasswor d";
this.lblPasswor d.Size = new System.Drawing. Size(136, 16);
this.lblPasswor d.TabIndex = 1;
this.lblPasswor d.Text = "Password:" ;
//
// lblUserId
//
this.lblUserId. Location = new System.Drawing. Point(8, 20);
this.lblUserId. Name = "lblUserId" ;
this.lblUserId. Size = new System.Drawing. Size(136, 16);
this.lblUserId. TabIndex = 0;
this.lblUserId. Text = "&Bruger Id:";
//
// frmLogin
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(304, 310);
this.Controls.A dd(this.gbxLogi n);
this.Icon = ((System.Drawin g.Icon)(resourc es.GetObject("$ this.Icon")));
this.MaximizeBo x = false;
this.MinimizeBo x = false;
this.Name = "frmLogin";
this.ShowInTask bar = false;
this.StartPosit ion = System.Windows. Forms.FormStart Position.Center Parent;
this.Text = "Administra tor login";
this.Load += new System.EventHan dler(this.frmLo gin_Load);
this.gbxLogin.R esumeLayout(fal se);
this.ResumeLayo ut(false);
}
#endregion
private void frmLogin_Load(o bject sender, System.EventArg s e)
{
}
private void btnLogin_Click( object sender, System.EventArg s e)
{
// Call from here errors,
seems to be looking locally for the method, not the public one in the other
form
EnableMenuOnLog in();
}
}
}
"Stoitcho Goutsev (100) [C# MVP]" wrote:
Hi Claus,
With the info you gave us it is really hard to tell.
What is 'test'?
Are the MDI container and MDI child in the same assembly? If not did you add
a reference to the container's assembly in the child project?
Did you use using statements? And so on. It is best if you perepate some
simple sample code that demonstrates the problem.
--
Stoitcho Goutsev (100) [C# MVP]
"Claus Holm" <Claus Ho**@discussion s.microsoft.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com... I'm trying to enable a menuitem in the parent form from a mdichild. Rather
than making the menuitems public, I'd go for a public method in the parent
form to do the change, but when I call the method from the mdichild, I get
this error:
C:\MyProjects\V isual Studio Projects\Tourna ment\Forms\frmL ogin.cs(69): The
name 'test' does not exist in the class or namespace 'Tournament.frm Login'
frmLogin is the mdichild.
What am I missing here?
Thanks,
Claus Holm