473,832 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to access the menustrip control an mdiparent from its mdi child

15 New Member
I am using C#.net.My problem is that
I have a MDI Parent form and on that I have menustrip control which i have disabled at the time of load of MDI parent.Now I have MDI child login form.
Now If the valid user sign in then only that menustrip should be enabled.
I used the below code on the "signin" button click event.
MDIparent form1=new MDIparent();
form1.menustrip 1.enabled=true;
(modifier of menustrip is public).

But this code is not working so may i know how to solve this problem.
May 13 '09 #1
7 11118
swatii
15 New Member
I am using C#.net.My problem is that
I have a MDI Parent form and on that I have menustrip control which i have disabled at the time of load of MDI parent.Now I have MDI child login form.
Now If the valid user sign in then only that menustrip should be enabled.
I used the below code on the "signin" button click event.
Expand|Select|Wrap|Line Numbers
  1. MDIparent form1=new MDIparent();
  2. form1.menustrip1.enabled=true;
  3.  
(modifier of menustrip is public).

But this code is not working so may i know how to solve this problem.
May 13 '09 #2
swatii
15 New Member
Is there any one who can solve my problem
May 13 '09 #3
tlhintoq
3,525 Recognized Expert Specialist
But this code is not working
What error do you get from this code?
May 13 '09 #4
swatii
15 New Member
@tlhintoq
I am not getting any error but this code is not working....I mean still menustrip control is disabled...
May 17 '09 #5
tlhintoq
3,525 Recognized Expert Specialist
@swatii
Expand|Select|Wrap|Line Numbers
  1. form1.menustrip1.enabled=true;
There is really no way to misinterpret this code as doing anything other than enabling menustrip1.

Now you are down to basic debugging.
Using breakpoints and walking through the code line by line may discover that you are NOT actually running this line. Or maybe there is another line elsewhere that is disabling the menu again. Or maybe the menustrip sits inside another control that is disabled. Or maybe you have more than one menustrip in your application and you are enabling the wrong one.

With only two lines of code provided its hard to give more advice.
May 17 '09 #6
balame2004
142 New Member
You are creating new instance for the parent form and trying to enable the menustrip of the form instance.Defini tely it won't work as you need to make the changes in the actual instance of the parent form. Pass the actual instance of the parent form to login form and make the changes in it.

Eg:

Add the following constructor to your login form.

private MDIparent parent=null;
public LoginForm(MDIpa rent parent)
{
this.parent=par ent;
}

in your parent form call the constructor like this:
LoginForm lgFrm=new LoginForm(this) ;

Enable the menustrip in signin button click event method as follows.

this.parent.men ustrip1.enabled =true;

It will work.
May 18 '09 #7
swatii
15 New Member
Wow ...This code works well thank you so much....Now I understand my mistake...
May 18 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1794
by: Lucas Graf | last post by:
This sounds so easy to me and feel like an idiot that I can't figure it out, but....how can I have a MDI child access it's parents control(s)?? Seems like it should be as easy as making the controls on the parent public, so i created a new project real quick w/2 forms. One is the MDIParent container and then one child form. On the MDIParent i put a textbox (textbox1) and set it to public. From the child code I just try to do a...
2
4107
by: Karl | last post by:
Hi, I'm just writing my first real c# application and I have a problem when trying to access a control in a child form. I am using an MDI application with a parent form called frmMain. In this code I need to parse some files whose filenames are in an arraylist. Since this parsing may take some time, I want to display a child form named frmProgress (created as frmProgessBar) that will show a ProgressBar and update it during processing.
2
2122
by: Gary Townsend | last post by:
I have seen similar requests to this but not quite what i was looking for i have an mdi interface and i have 3 child forms 2 are application forms (meaning they do stuff for the application) and the other is a debug window with a multiline text field for displaying debug messages within the application. What happens is i load the debug form on the mdi parents load event and minimize it then i load my application forms. What i want to...
0
1851
by: rellik | last post by:
Hi All, I've run into a problem with the MenuStrip control and any help would be greatly appreciated! The problem I've got is that when use a control derived from the MenuStrip class all MDI merge functionality breaks - each MDI child window is given it's own menu rather than the mdi parent. To repeat the problem just create a very simple dummy app that has standard
0
1656
by: Chris Peeters | last post by:
Hi, I have an MDI-application running with 1 MDI chilld showing in 'Normal'-WindowState, so NOT maximized. What I see is the MDI-main window showing its title bar, below that the menustrip with merged-menuitems and the MDI-child window 'floating' within the MDI-container just showing an icon + title in its title bar. So far so good. But when I maximize the MDI-child window ... what i see then is the
0
1544
by: =?Utf-8?B?UnVieSBOYWRsZXI=?= | last post by:
Hi everyone, i am trying to set control on mdi form from mdi child: trying to set toolstrip on mdi parent (MDIMain) from child form doing this way on the child form: ToolStrip Tool = ((MDIMain)this.MdiParent).toolStrip; Tool.Enabled = false; or this way ((MDIMain)this.MdiParent).toolStrip.Enabled = false;
3
6578
by: ssknov | last post by:
hi i am creating a login page.Inthe form load itself i need to hide the MenuStrip in MDI Parent to HIDE, When the users gives the correct passwd and pushes the Loginbutton , My MDIParent1 forms menustrip should be visible . c my code . but it doesnt works. Any body pls clear my doubt. private void LoginForm_Load(object sender, EventArgs e) {
1
1950
by: win | last post by:
There is a menustrip on the MDI parent window. When i add a menustrip on the MDI child window, the menu options appear on the MDI parent menustript. How can the MDI child window have its own menustrip? Thanks a lot.
8
5261
by: JonnyBlaze | last post by:
Hi Guys - This is my first C# app, but I have some knowledge of a bunch of languages like VB6 and PHP, so I'm picking it up rather quickly. I've been pulling my hair out on this one for about 4 hours now. I have a DirectoryInfo on my parent form: (extra bits chopped out...) public partial class frmMain : Form { public DirectoryInfo diTemp;
0
9794
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10780
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10497
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9319
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7753
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5623
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4420
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.