?
Solved

C# Windows App

Posted on 2004-04-14
5
Medium Priority
?
309 Views
Last Modified: 2010-04-15
Hello,

I have a Main form 'Parent' and in that form i have a button 'A'. if i click on the button 'A' in the parent form it takes me to a differnt form 'Child'. (like this)

frmA dr = new frmA();
dr.Show();

In 'Child' i have 2 buttons. One: Submit Second: Clear/Close. I have implemented all the funtionality for the 'Child' form.
After validating the 'Child' form the Submit button gets disabled and Clear button becomes Close button.

Now My question is::

When i click the Close button i want the Button 'A' in the 'Parent' form also to get disabled. I mean, After validating, submitting and closing the  child form the Button on the Parent form should also get disabled. How can i do it?
0
Comment
Question by:karra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
int_20h earned 60 total points
ID: 10826171
you can pass the parent instance to the child form and create a public method in the parent that sets a boolean to disable the button.  In the child form, after validating the input, call the public method in the parent to disable the button.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10826585
you can also have the child form raise an event that the parent catches and then have the parent change the button state
0
 

Author Comment

by:karra
ID: 10826878
Can some one show me an example please?
0
 
LVL 37

Assisted Solution

by:gregoryyoung
gregoryyoung earned 90 total points
ID: 10827090
of my method ?

            public delegate void DisableButtonEventHandler(object sender, EventArgs e);
            public event DisableButtonEventHandler DisableButton;

            protected virtual void OnDisableButton(EventArgs e) {
                  if (DisableButton != null)
                        DisableButton(this, e);
            }
Child foo = new Child() ;
foo.DisableButton += new DisableuttonEventHandler(this.methodtohandle);

when you want the button disabled call OnDisableButton then trap the event in the parent the way you would any other event ... this also allows other things to trap it in the future


of his Method ...

You add a property to the child of parent (type is type of the parent)

Add a public  method to the parent DisableButton()

then in the child you say Parent.DisableButton() when you want it to be disabled

once done this allows easier future exchanges between the parent and child ...
0
 

Author Comment

by:karra
ID: 10843216
I got along with this problem with a easy answer.

child.ShowDialog(this);
if(!child.IsAccessible)
    btnChild.Enabled = false;
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

762 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