|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
events (forms)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! *** Sent via Developersdex http://www.developersdex.com *** article here will help:
http://www.eggheadcafe.com/articles/20040229.asp --Peter "Inside every large program, there is a small program trying to get out." http://www.eggheadcafe.com http://petesbloggerama.blogspot.com http://www.blogmetafinder.com Show quote "csharpula csharp" wrote: > 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! > > > > *** Sent via Developersdex http://www.developersdex.com *** > On Nov 29, 12:06 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.com> wrote: The recommendation of using the "sender" parameter for arbitrary data seems like a bad idea to me. The sender parameter has a clearly defined role: it should be the object raising the event. If the event logically takes arguments (e.g. a message to display) that's what the second parameter is for. Jon You are correct, it should be sent in a custom EventArgs - derived class. Old
article. --Peter "Inside every large program, there is a small program trying to get out." http://www.eggheadcafe.com http://petesbloggerama.blogspot.com http://www.blogmetafinder.com Show quote "Jon Skeet [C# MVP]" wrote: > On Nov 29, 12:06 pm, Peter Bromberg [C# MVP] > <pbromb...@yahoo.NoSpamMaam.com> wrote: > > article here will help:http://www.eggheadcafe.com/articles/20040229.asp > > The recommendation of using the "sender" parameter for arbitrary data > seems like a bad idea to me. The sender parameter has a clearly > defined role: it should be the object raising the event. If the event > logically takes arguments (e.g. a message to display) that's what the > second parameter is for. > > Jon > 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! *** Sent via Developersdex http://www.developersdex.com *** On Nov 29, 4:02 pm, csharpula csharp <csharp***@yahoo.com> wrote:
> It is not helping in my case because I need a communication between 2 That's irrelevant - why would they need to be in an inheritance> forms which are not in inheritence relatioship 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! *** Sent via Developersdex http://www.developersdex.com *** 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. Show quote "csharpula csharp" <csharp***@yahoo.com> kirjutas sõnumis news:%23DPGmJrMIHA.5208@TK2MSFTNGP04.phx.gbl... > > > 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! > > *** Sent via Developersdex http://www.developersdex.com *** Andrus <kobrule***@hot.ee> wrote:
> 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 Well, at that point it's not really an event in .NET terms - it's just > > foreach (Form o in this.MdiParent.MdiChildren) > > ((IMyEvents)o).MyEvent(); a plain method. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet World class .NET training in the UK: http://iterativetraining.co.uk csharpula csharp <csharp***@yahoo.com> wrote:
> The question is how form2 will know about the event if it has no istance Well it will clearly need to know about the instance of form1 in some > of form 1? (which published it) 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. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet World class .NET training in the UK: http://iterativetraining.co.uk On Thu, 29 Nov 2007 01:54:15 -0800, csharpula csharp
<csharp***@yahoo.com> wrote: >Hello, Check out my example in reply to your 'Design GUI' question on 28th>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! > > > >*** Sent via Developersdex http://www.developersdex.com *** Hi, Nov. regards Bob |
|||||||||||||||||||||||