469,271 Members | 1,697 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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

15
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.menustrip1.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 10728
swatii
15
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
Is there any one who can solve my problem
May 13 '09 #3
tlhintoq
3,525 Expert 2GB
But this code is not working
What error do you get from this code?
May 13 '09 #4
swatii
15
@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 Expert 2GB
@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 100+
You are creating new instance for the parent form and trying to enable the menustrip of the form instance.Definitely 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(MDIparent parent)
{
this.parent=parent;
}

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.menustrip1.enabled=true;

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

Post your reply

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

Similar topics

1 post views Thread by Lucas Graf | last post: by
reply views Thread by Chris Peeters | last post: by
reply views Thread by =?Utf-8?B?UnVieSBOYWRsZXI=?= | last post: by
1 post views Thread by win | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.