Solved

MDI Forms

Posted on 2004-09-10
12
270 Views
Last Modified: 2010-04-15
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.
0
Comment
Question by:reclusive
  • 6
  • 4
  • 2
12 Comments
 
LVL 8

Expert Comment

by:gregasm
ID: 12031051
on the MDI parent form, during design time, click on the menu item and in the properties dialog box, select the access modifier PUBLIC.

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.Parent).mnuMain.items(1)....

you know what i mean? let me know if you dont...

have a look here also.
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21007358.html
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12032256
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=true to set the menu you want to be enabled
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12032371
tzxie2000, if you read the responses, you can avoid wasting your time and writing the same thing someone else has already said.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 5

Expert Comment

by:tzxie2000
ID: 12032417
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
0
 
LVL 1

Author Comment

by:reclusive
ID: 12033343
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=true and ((frmMdiParent)frmChild.Parent).mnuMain.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...
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12033368
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.Enabled=true;

you can get what you want
0
 
LVL 1

Author Comment

by:reclusive
ID: 12033386
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?
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12033396
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
0
 
LVL 1

Author Comment

by:reclusive
ID: 12033419
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");
0
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 125 total points
ID: 12033433
please change the mdiform to the main mdi container form name in your project

the mdiform in my code is the main mdi container form name

it  is not a property of the form

sorry for misunderstand
0
 
LVL 1

Author Comment

by:reclusive
ID: 12033451
WICKED!!! it works!! thanks
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12033494
you are welcome
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now