events (forms)

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I want to invoke event in one form which will be sent to other form
(both forms has nothing in common) . Could someone plz refer me to good
example for doing it? Thank you!
 
It is not helping in my case because I need a communication between 2
forms which are not in inheritence relatioship .Hoc can I change value
of one control basing on change that occured on other form? (no
inheritence between forms) Thank you!
 
It is not helping in my case because I need a communication between 2
forms which are not in inheritence relatioship

That's irrelevant - why would they need to be in an inheritance
relationship?

One form just needs to publish an event, and the other form needs to
know about the first form.

Jon
 
The question is how form2 will know about the event if it has no istance
of form 1? (which published it) I am just looking for an example of
event invoking in such case.If someone can send me a link of such
example that will really help. Thank you!
 
You are right, delegates are useless in WinForms event invoking.

Your forms should implement common interface and use it like

foreach (Form o in this.MdiParent.MdiChildren)

((IMyEvents)o).MyEvent();

Andrus.
 
csharpula csharp said:
The question is how form2 will know about the event if it has no istance
of form 1? (which published it)

Well it will clearly need to know about the instance of form1 in some
way or other, but that has very little to do with inheritance.

You could pass a reference to form1 to the constructor of form2, or
something similar.
 
Andrus said:
You are right, delegates are useless in WinForms event invoking.

Eh? What on earth do you mean by that? Delegates are the whole basis of
events in .NET, including WinForms events.
Your forms should implement common interface and use it like

foreach (Form o in this.MdiParent.MdiChildren)

((IMyEvents)o).MyEvent();

Well, at that point it's not really an event in .NET terms - it's just
a plain method.
 
Hello,
I want to invoke event in one form which will be sent to other form
(both forms has nothing in common) . Could someone plz refer me to good
example for doing it? Thank you!
Hi,
Check out my example in reply to your 'Design GUI' question on 28th
Nov.
regards
Bob
 
Back
Top