Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
GeneralRe: Thread Safe Form Controls Pin
Luc Pattyn25-Oct-09 13:44
sitebuilderLuc Pattyn25-Oct-09 13:44 
GeneralRe: Thread Safe Form Controls Pin
N a v a n e e t h25-Oct-09 20:14
N a v a n e e t h25-Oct-09 20:14 
GeneralRe: Thread Safe Form Controls [modified] Pin
Luc Pattyn26-Oct-09 0:45
sitebuilderLuc Pattyn26-Oct-09 0:45 
GeneralRe: Thread Safe Form Controls Pin
N a v a n e e t h26-Oct-09 15:59
N a v a n e e t h26-Oct-09 15:59 
GeneralRe: Thread Safe Form Controls Pin
Luc Pattyn25-Oct-09 14:06
sitebuilderLuc Pattyn25-Oct-09 14:06 
QuestionCalling functions or checking objects of one form from another (MDI project) Pin
helkhoury25-Oct-09 8:32
helkhoury25-Oct-09 8:32 
AnswerRe: Calling functions or checking objects of one form from another (MDI project) Pin
DaveyM6925-Oct-09 9:06
professionalDaveyM6925-Oct-09 9:06 
AnswerRe: Calling functions or checking objects of one form from another (MDI project) [modified] Pin
Ekoj Lirpa25-Oct-09 9:42
Ekoj Lirpa25-Oct-09 9:42 
Well, generally, how can an object call a mrthod of an other object? Well, the calling object must have a reference to the other object and with this reference it can call any public method of the referenced object. Your two forms are objects, so this will work for them too.

C# does not have anything like global variables for a good reason. There are some things which come close, like static methods and variables, but these things should be used with some caution. Using them carelessly can easily result in a program which is buggy, hard to correct and maintain and generally a pain to work on. I understand that a beginner tries to focus on getting the job done, but when you have been in code hell a few times you will see that that reaching the goal is not all.

As a rule of thumb: If you have to tweak your code, there always is something wrong with your design. Object oriented design in this case. Now let's see...

This is the simplest but certainly not the best way to do it: Let's say there is form A which must be notified when a certain thing happens to form B. When form B is opened it receives a reference to it's partner, form A. Whenever something happens to form B which form A must get to know about, form B can use this reference to call methods of form A.

Edit: I just saw the reply before mine. Notifying the parent with an event which in turn decides which children are to be notified is indeed a much cleaner design. It also probably will involve a little more reading articles and learning.

modified on Sunday, October 25, 2009 3:50 PM

GeneralRe: Calling functions or checking objects of one form from another (MDI project) Pin
helkhoury25-Oct-09 10:40
helkhoury25-Oct-09 10:40 
GeneralRe: Calling functions or checking objects of one form from another (MDI project) Pin
helkhoury25-Oct-09 10:53
helkhoury25-Oct-09 10:53 
GeneralRe: Calling functions or checking objects of one form from another (MDI project) Pin
Ekoj Lirpa25-Oct-09 12:15
Ekoj Lirpa25-Oct-09 12:15 
Questionwho can help me? Pin
Abdaqader25-Oct-09 7:34
Abdaqader25-Oct-09 7:34 
AnswerRe: who can help me? Pin
Richard MacCutchan25-Oct-09 8:02
mveRichard MacCutchan25-Oct-09 8:02 
AnswerRe: who can help me? Pin
Abhishek Sur25-Oct-09 8:42
professionalAbhishek Sur25-Oct-09 8:42 
AnswerRe: who can help me? Pin
Christian Graus25-Oct-09 9:16
protectorChristian Graus25-Oct-09 9:16 
AnswerRe: who can help me? Pin
Pete O'Hanlon25-Oct-09 12:10
mvePete O'Hanlon25-Oct-09 12:10 
GeneralRe: who can help me? Pin
Gerry Schmitz25-Oct-09 17:13
mveGerry Schmitz25-Oct-09 17:13 
GeneralRe: who can help me? Pin
Mycroft Holmes25-Oct-09 18:11
professionalMycroft Holmes25-Oct-09 18:11 
Questionwho can help me Pin
Abdaqader25-Oct-09 7:34
Abdaqader25-Oct-09 7:34 
AnswerRe: who can help me Pin
Dave Kreskowiak25-Oct-09 8:14
mveDave Kreskowiak25-Oct-09 8:14 
GeneralRe: who can help me Pin
Ekoj Lirpa25-Oct-09 8:59
Ekoj Lirpa25-Oct-09 8:59 
GeneralRe: who can help me Pin
Abhishek Sur25-Oct-09 12:09
professionalAbhishek Sur25-Oct-09 12:09 
GeneralRe: who can help me Pin
Christian Graus25-Oct-09 9:21
protectorChristian Graus25-Oct-09 9:21 
Questiontables Pin
csrss25-Oct-09 7:13
csrss25-Oct-09 7:13 
AnswerRe: tables Pin
Richard MacCutchan25-Oct-09 7:39
mveRichard MacCutchan25-Oct-09 7:39 

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.