Solved

C# Windows App

Posted on 2004-04-14
5
307 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 20 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 30 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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