reclusive
asked on
MDI Forms
I have a MDI application I'm working on that is giving me a headache. The MDIparent (frmMain) has a main menu (mnuMain). All but the &File menu are disabled on form laod and one of the MDIchild forms (frmLogon) is displayed. I want to enable the additional menu's when a correct login is detected in frmLogon.OK button. So far all I have been able to find are examples on how to pass values from one text box on one form to another - Yeah this helped... But it still did not answer my problem... This is being done in c#.net 2003 Professional.
in C#
you should change the parent form's main menu value which is MainMenu.modifiers to public in IDE
and in logon button please use
(MDIForm)(this.ParentForm) .MainMenu. Items[???] .Enabled=t rue to set the menu you want to be enabled
you should change the parent form's main menu value which is MainMenu.modifiers to public in IDE
and in logon button please use
(MDIForm)(this.ParentForm)
tzxie2000, if you read the responses, you can avoid wasting your time and writing the same thing someone else has already said.
Please notice that the different between C# and VB
as in C# you should set modifiers from private to public but int VB is not
and use frm.Parent may get mistake in C#, you should use this.ParentForm
as in C# you should set modifiers from private to public but int VB is not
and use frm.Parent may get mistake in C#, you should use this.ParentForm
ASKER
Neither of your examples work... I have changed the access modifiers on the MDIparent to public and in the MDIchild's ok button I have attempted to insert both : (MDIForm)(this.ParentForm) .MainMenu. Items[???] .Enabled=t rue and ((frmMdiParent)frmChild.Pa rent).mnuM ain.items( 1) and it does not work. Before you ask yes I have tried all variations fo the code to get it to work... Could you please explain the syntax a bit more clrearly for me? I am still new to C# and it is a bit fuzzy at times...
ok
there may be some not clear in before comment
look detail comment below
suggest in mdiform's mainmenu you have an menuitem name MenuItemChange;
click on it and modify its modifiers to public in IDE
in your logform.okbutton's click event enter this code
(this.MdiParent as MDIForm).menuItemChange.En abled=true ;
you can get what you want
there may be some not clear in before comment
look detail comment below
suggest in mdiform's mainmenu you have an menuitem name MenuItemChange;
click on it and modify its modifiers to public in IDE
in your logform.okbutton's click event enter this code
(this.MdiParent as MDIForm).menuItemChange.En
you can get what you want
ASKER
There is no option in the option in the mdiChild to insert : (this.MdiParent as MDIForm... after the "as" all I have is MdiClient and Mdi Layout. I have changed the access modifiers to public on my MdiParent form and done exactly what tyou said *erk* Is there something I am missing?
could you paste your code in the okbutton click event?
it is suprise that you can only get two option
I always get hundreds of options
it is suprise that you can only get two option
I always get hundreds of options
ASKER
if( GoodLogin == true )
{
// this is wher eI am trying to enable my menu if it is a correct logon
(this.mdiparent as mdi
frmLogon FM = new frmLogon();
this.Hide();
FM.ShowDialog();
Close();
}
else
MessageBox.Show("Invalid Credential");
{
// this is wher eI am trying to enable my menu if it is a correct logon
(this.mdiparent as mdi
frmLogon FM = new frmLogon();
this.Hide();
FM.ShowDialog();
Close();
}
else
MessageBox.Show("Invalid Credential");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WICKED!!! it works!! thanks
you are welcome
Then in the child window, you'll want to cast the parent property of the child into the main form and then you can access the menu object and enable whatever you please.
The code might look something like this.
((frmMdiParent)frmChild.Pa
you know what i mean? let me know if you dont...
have a look here also.
https://www.experts-exchange.com/questions/21007358/enable-disable-control-on-mdi-parent.html