Solved

C# Windows App

Posted on 2004-04-14
5
306 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to read json value 2 49
Greetings C# program 17 107
ASP.NET 5 Templates 2 78
Hey Audio! 3 29
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!
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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