Solved

C# Windows App

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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 video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

728 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