473,387 Members | 1,579 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,387 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 3539

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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.