473,239 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

How to tell parent window when a child window is clilcked on?

What is the mechanism by which a child window can notify its parent that it
has been clicked on?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Aug 24 '06 #1
4 3532

Richard Lewis Haggard wrote:
What is the mechanism by which a child window can notify its parent that it
has been clicked on?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Can't you just have the parent form listen to the child form's Click
event?

If you need more specific behaviour, you could write a new event into
the child form and have the parent form subscribe to that event.

Aug 24 '06 #2
Thank you, but restating the question does not actually provide any useful
information that will help solve the problem. I need to know how to set up
things so that a child window can notify its parent of an event in a child.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
>
Richard Lewis Haggard wrote:
>What is the mechanism by which a child window can notify its parent that
it
has been clicked on?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

Can't you just have the parent form listen to the child form's Click
event?

If you need more specific behaviour, you could write a new event into
the child form and have the parent form subscribe to that event.

Aug 27 '06 #3

Richard Lewis Haggard wrote:
Thank you, but restating the question does not actually provide any useful
information that will help solve the problem. I need to know how to set up
things so that a child window can notify its parent of an event in a child.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...

Richard Lewis Haggard wrote:
What is the mechanism by which a child window can notify its parent that
it
has been clicked on?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Can't you just have the parent form listen to the child form's Click
event?

If you need more specific behaviour, you could write a new event into
the child form and have the parent form subscribe to that event.
What part of "...have the parent form subscribe to that event" was
unclear?

If you are looking for code, this is what I meant:

public class ParentForm : Form
{
...
ChildForm child = new ChildForm();
child.Click += new System.EventHandler(child_Click);
child.Show();
...

private void child_Click(object sender, System.EventArgs e)
{
MessageBox.Show("The child was clicked!");
}
}

Of course, this event will occur only when the user clicks on the child
form itself and not on any of the controls contained within the form.
(Clicks on controls within the child form will, of course, be handled
by those controls and will not be seen as a Click on the form.)

If this isn't what you want, then perhaps the problem is in how you
stated your question. "Click on the child form" could mean precisely
that: a click event on the child form, in which case the above code is
what you need. Or, perhaps you meant "when the user gives the child
form focus" in which case the GotFocus event might be more appropriate.

It may also make a difference whether you are programming WinForms
(which is what I do) or WebForms (I can't speak to the subtleties of
Web programming).

As well, what you mean by "when the user clicks on the child form" may
be when the user clicks *anywhere* within the bounds of child form,
even on a control, which is a whole other kettle of fish.

The problem, from my side of the Web, is that your question is rather
vague. The child form doesn't "notify the parent of an event in the
child". The parent, rather, subscribes to one of the child's events,
and so registers its interest in something that may happen within the
child form. Are you having trouble in the parent, subscribing to
events? Or do none of the standard events for a Form meet your needs?
Or perhaps you're subscribing but your handler is never called? Or
perhaps you're using the word "event" in a general (English) sense
rather than in the technical sense of a C# event?

Rather than tossing back ironic comments, perhaps providing more
information about exactly what it is you're trying to do would get you
a better answer.

Aug 27 '06 #4
Ah! Now I understand what you meant. I knew that there must some easy way of
doing it but couldn't figure out the right keys to push in order to
accomplish the desired result. Thanks!
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>
Richard Lewis Haggard wrote:
>Thank you, but restating the question does not actually provide any
useful
information that will help solve the problem. I need to know how to set
up
things so that a child window can notify its parent of an event in a
child.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@m79g2000cwm.googleg roups.com...
>
Richard Lewis Haggard wrote:
What is the mechanism by which a child window can notify its parent
that
it
has been clicked on?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

Can't you just have the parent form listen to the child form's Click
event?

If you need more specific behaviour, you could write a new event into
the child form and have the parent form subscribe to that event.

What part of "...have the parent form subscribe to that event" was
unclear?

If you are looking for code, this is what I meant:

public class ParentForm : Form
{
...
ChildForm child = new ChildForm();
child.Click += new System.EventHandler(child_Click);
child.Show();
...

private void child_Click(object sender, System.EventArgs e)
{
MessageBox.Show("The child was clicked!");
}
}

Of course, this event will occur only when the user clicks on the child
form itself and not on any of the controls contained within the form.
(Clicks on controls within the child form will, of course, be handled
by those controls and will not be seen as a Click on the form.)

If this isn't what you want, then perhaps the problem is in how you
stated your question. "Click on the child form" could mean precisely
that: a click event on the child form, in which case the above code is
what you need. Or, perhaps you meant "when the user gives the child
form focus" in which case the GotFocus event might be more appropriate.

It may also make a difference whether you are programming WinForms
(which is what I do) or WebForms (I can't speak to the subtleties of
Web programming).

As well, what you mean by "when the user clicks on the child form" may
be when the user clicks *anywhere* within the bounds of child form,
even on a control, which is a whole other kettle of fish.

The problem, from my side of the Web, is that your question is rather
vague. The child form doesn't "notify the parent of an event in the
child". The parent, rather, subscribes to one of the child's events,
and so registers its interest in something that may happen within the
child form. Are you having trouble in the parent, subscribing to
events? Or do none of the standard events for a Form meet your needs?
Or perhaps you're subscribing but your handler is never called? Or
perhaps you're using the word "event" in a general (English) sense
rather than in the technical sense of a C# event?

Rather than tossing back ironic comments, perhaps providing more
information about exactly what it is you're trying to do would get you
a better answer.

Sep 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe D | last post by:
I think this is a simple question. But I am new to JS. Here is what I want to do: From a parent window, open a popup window (child) to get data from user, then user submit the request, close the...
4
by: webdev | last post by:
Hi, I have an application built for the education market in which I open popup windows containing ASP scripts which when the user clicks the 'Update' button, the database is updated and the...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
2
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
2
by: epaetz | last post by:
Is there a way to decouple the linkage between a parent and a child window? Does the parent window have any sort of a collection that holds all the children that it has spawned? I want to...
0
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi just wondering if anyone knows if there is a way to tell if a child window is still open in the code behind in the parent window (web application vs.net 2005)? I have a web app and am using the...
1
Frinavale
by: Frinavale | last post by:
I'm having a problem that I cannot seem to debug. FireFox's FireBug extension is indicating that there is an error being thrown, but I have no idea which window caused the error to be thrown. I...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.