Click here to Skip to main content
15,903,030 members
Home / Discussions / C#
   

C#

 
GeneralRe: Validating event in a Dialog form Pin
Wendelius10-Sep-08 8:02
mentorWendelius10-Sep-08 8:02 
Question[Message Deleted] Pin
Yathish hatter9-Sep-08 4:29
Yathish hatter9-Sep-08 4:29 
AnswerRe: please Help me C# Pin
Anthony Mushrow9-Sep-08 4:33
professionalAnthony Mushrow9-Sep-08 4:33 
AnswerRe: please Help me C# [modified] Pin
BillW339-Sep-08 5:32
professionalBillW339-Sep-08 5:32 
AnswerRe: please Help me C# Pin
zafersavas9-Sep-08 5:58
zafersavas9-Sep-08 5:58 
GeneralRe: please Help me C# Pin
DaveyM699-Sep-08 7:10
professionalDaveyM699-Sep-08 7:10 
GeneralRe: please Help me C# Pin
zafersavas9-Sep-08 8:31
zafersavas9-Sep-08 8:31 
GeneralRe: please Help me C# Pin
DaveyM699-Sep-08 8:53
professionalDaveyM699-Sep-08 8:53 
Form2 has no purpose to know about form1 at all. It does nothing with it at all so the reference it pointless.
Form1 however neeeds to know when form2 is closing so it should listen for that event.

That's what events and delegates are designed for. If any object needs to tell any other objects about anything at all it should raise an event so any interested (subscribed) objects can react.


zafersavas wrote:
What if you have form3, form4 etc.


This applies the other way too - what if you have multiple objects that need to know that form2 is closing? You'd need to pass every object in the constructor. How can you predetermine how many there will be or what types? It makes the constructor(s) virtually unmaintainable. By using events/delegates there is no limit to the number or type of objects that can have methods invoked from the object raising the event.

That's what OOP is all about! Big Grin | :-D

Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog)

GeneralRe: please Help me C# Pin
zafersavas9-Sep-08 10:00
zafersavas9-Sep-08 10:00 
GeneralRe: please Help me C# Pin
DaveyM699-Sep-08 10:27
professionalDaveyM699-Sep-08 10:27 
GeneralRe: please Help me C# Pin
Mycroft Holmes9-Sep-08 15:46
professionalMycroft Holmes9-Sep-08 15:46 
GeneralRe: please Help me C# Pin
DaveyM699-Sep-08 23:07
professionalDaveyM699-Sep-08 23:07 
AnswerRe: please Help me C# Pin
nelsonpaixao9-Sep-08 14:11
nelsonpaixao9-Sep-08 14:11 
Questionis there any body in all the world can help me Pin
Miss_hacker9-Sep-08 3:42
Miss_hacker9-Sep-08 3:42 
AnswerRe: is there any body in all the world can help me Pin
Pete O'Hanlon9-Sep-08 4:06
mvePete O'Hanlon9-Sep-08 4:06 
AnswerRe: is there any body in all the world can help me Pin
J4amieC9-Sep-08 4:07
J4amieC9-Sep-08 4:07 
GeneralRe: is there any body in all the world can help me Pin
Pete O'Hanlon9-Sep-08 4:29
mvePete O'Hanlon9-Sep-08 4:29 
GeneralRe: is there any body in all the world can help me Pin
Paul Conrad9-Sep-08 6:43
professionalPaul Conrad9-Sep-08 6:43 
QuestionSet the light/siren device on in C# Pin
khuzwayom9-Sep-08 2:33
khuzwayom9-Sep-08 2:33 
AnswerRe: Set the light/siren device on in C# Pin
Pete O'Hanlon9-Sep-08 2:37
mvePete O'Hanlon9-Sep-08 2:37 
AnswerRe: Set the light/siren device on in C# Pin
zafersavas9-Sep-08 5:34
zafersavas9-Sep-08 5:34 
AnswerRe: Set the light/siren device on in C# Pin
Thomas Stockwell9-Sep-08 8:45
professionalThomas Stockwell9-Sep-08 8:45 
JokeRe: Set the light/siren device on in C# Pin
DaveyM699-Sep-08 9:14
professionalDaveyM699-Sep-08 9:14 
JokeRe: Set the light/siren device on in C# Pin
Mycroft Holmes9-Sep-08 16:05
professionalMycroft Holmes9-Sep-08 16:05 
AnswerRe: Set the light/siren device on in C# Pin
leppie9-Sep-08 21:50
leppie9-Sep-08 21:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.