473,385 Members | 1,329 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,385 software developers and data experts.

MDI Parent call MID Child events, methods

Hi all
What need to be done to get the MDI parent call his MDI children Events,
methods

Thanks in advance
/WS
Nov 16 '05 #1
8 3728
Hi,

If you want MDI parent call its child method then give that method
a "public" accesor.

I'm not really sure what you want to call child event for?
Don't you want to add handle to that child's event?
If so, then i don't see any problem, e.g. add event handler in child
initializing block.

If i missed somethig then don't affraid to feedback.

regards
Marcin
Hi all
What need to be done to get the MDI parent call his MDI children Events,
methods

Thanks in advance
/WS

Nov 16 '05 #2
Yes, will be great:
Would you like to explain more detail about how to define this event,
and to work with

Thanks, regards
/WS

"Marcin Grzębski" <mg*******@taxussi.spamstop.com.spamstop.pl> wrote in
message news:ct***********@mamut1.aster.pl...
Hi,

If you want MDI parent call its child method then give that method
a "public" accesor.

I'm not really sure what you want to call child event for?
Don't you want to add handle to that child's event?
If so, then i don't see any problem, e.g. add event handler in child
initializing block.

If i missed somethig then don't affraid to feedback.

regards
Marcin
Hi all
What need to be done to get the MDI parent call his MDI children Events,
methods

Thanks in advance
/WS

Nov 16 '05 #3

"Waleed Seada" <ds**********@hotmail.com> schrieb im Newsbeitrag
news:eR**************@TK2MSFTNGP14.phx.gbl...
Hi all
What need to be done to get the MDI parent call his MDI children Events,
methods

Thanks in advance
/WS


Maybe you mean such like this:
MdiClientForm f = new MdiClientForm();
f.Show();

// Add Handler when you create a new child form (for example closed handler)
f.Closed += new EventHandler(MdiClientForm_Closed);
// Handle Events here
private void MdiClientForm_Closed(object sender, System.EventArgs e)
{
}

Nov 16 '05 #4
If you want to call methods or respond to events that are specific to
the children form classes (outside of the base set for Forms) it may
help to define an abstract class for the children to inherit from or an
interface for them to mix in. This way you can iterate through the
children and to call methods or create more generic routines for
assigning event handlers to new child forms as they are created at
runtime. I don't know if this is exactly what you are trying to do,
but if it is I hope it helps.

-Dan Shanyfelt

Nov 16 '05 #5
I understand what "Torsten" said, Could you illustrate more detail, please
Thanks
Waleed Seada

<da*************@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
If you want to call methods or respond to events that are specific to
the children form classes (outside of the base set for Forms) it may
help to define an abstract class for the children to inherit from or an
interface for them to mix in. This way you can iterate through the
children and to call methods or create more generic routines for
assigning event handlers to new child forms as they are created at
runtime. I don't know if this is exactly what you are trying to do,
but if it is I hope it helps.

-Dan Shanyfelt

Nov 16 '05 #6
Hi,

You should explain what you want to achieve, first.
If you don't know how to define your own event then you should
read some docs or C# books to learn how it works.

Marcin
Yes, will be great:
Would you like to explain more detail about how to define this event,
and to work with

Thanks, regards
/WS

Nov 16 '05 #7
I already did, what I want to do is to implement what I have read, and with
examples, I will be able to decide
I want to create a custom treeview control, then add some events and methods
for it to work

How simply by defining one method and one event I can get it to work, can
you help me in this please

Thanks for your help
Waleed Seada
"Marcin Grzębski" <mg*******@taxussi.spamstop.com.spamstop.pl> wrote in
message news:ct***********@mamut1.aster.pl...
Hi,

You should explain what you want to achieve, first.
If you don't know how to define your own event then you should
read some docs or C# books to learn how it works.

Marcin
Yes, will be great:
Would you like to explain more detail about how to define this event,
and to work with

Thanks, regards
/WS

Nov 16 '05 #8
-to make the "abstract" form:

public class abForm : System.Windows.Forms.Form

//public abstract class abForm : System.Windows.Forms.Form
//making this a real abstract class messes with the form designer but
will still work

public void MakeRed()
{
this.BackColor = System.Drawing.Color.Red;
}

-to make the child forms

public class F2 : abForm
public class F3 : abForm

-in the mdi form
private void mdi_Load(object sender, System.EventArgs e)
{
F2 ff2 = new F2();
ff2.MdiParent = this;
ff2.Show();
F3 ff3 = new F3();
ff3.MdiParent = this;
ff3.Show();
}

private void button1_Click(object sender, System.EventArgs e)
{
foreach (Form f in this.MdiChildren)
{
((abForm) f).MakeRed();
}
}

The same principle would apply to events. If there is a way to make
the abstract form in a cleaner way (still allowing for the abstract
keyword without breaking the designer for the forms that inherit from
it), I hope one of the experts on this board will explain. The other
option would be to create an interface that specifies the MakeRed
method. The only reason to make the "abstract" form is that you don't
have to write the code inside MakeRed for every inherited form.
-Dan Shanyfelt

Nov 16 '05 #9

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

Similar topics

1
by: Filiz Duman | last post by:
Is it possible to call a javascript function based in the parent window from the child window ? I do open a pop up window from the parent window with: newwindow = window.open (...) and assign...
9
by: Martin Herbert Dietze | last post by:
Hello, I would like to implement a callback mechanism in which a child class registers some methods with particular signatures which would then be called in a parent class method. In...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
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...
3
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a...
0
by: uupi_duu | last post by:
Hello, I have a parent class which creates and uses child class. Child class use it's own methods for different tasks. If an error occurs in child classes methods I would like to inform it to...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
3
by: O.B. | last post by:
I have a form that shows another child form using the Show() operation. Since the child is modaless, I would like the option that when I click anywhere on the parent form that the parent form...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
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...

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.