Click here to Skip to main content
15,906,645 members
Home / Discussions / C#
   

C#

 
QuestionAdd BMP header into raw file Pin
Game-point25-Oct-09 18:47
Game-point25-Oct-09 18:47 
AnswerRe: Add BMP header into raw file Pin
Christian Graus25-Oct-09 18:53
protectorChristian Graus25-Oct-09 18:53 
GeneralRe: Add BMP header into raw file Pin
Game-point25-Oct-09 19:02
Game-point25-Oct-09 19:02 
GeneralRe: Add BMP header into raw file Pin
Christian Graus25-Oct-09 19:06
protectorChristian Graus25-Oct-09 19:06 
GeneralRe: Add BMP header into raw file Pin
Game-point25-Oct-09 19:18
Game-point25-Oct-09 19:18 
GeneralRe: Add BMP header into raw file Pin
Christian Graus25-Oct-09 19:22
protectorChristian Graus25-Oct-09 19:22 
QuestionHow to get value from the listbox in Form2 to display in Form1 Textbox? Pin
Zar Ni25-Oct-09 16:58
Zar Ni25-Oct-09 16:58 
AnswerRe: How to get value from the listbox in Form2 to display in Form1 Textbox? Pin
N a v a n e e t h25-Oct-09 17:17
N a v a n e e t h25-Oct-09 17:17 
GeneralRe: How to get value from the listbox in Form2 to display in Form1 Textbox? Pin
Zar Ni25-Oct-09 17:28
Zar Ni25-Oct-09 17:28 
GeneralRe: How to get value from the listbox in Form2 to display in Form1 Textbox? Pin
N a v a n e e t h25-Oct-09 17:43
N a v a n e e t h25-Oct-09 17:43 
GeneralRe: How to get value from the listbox in Form2 to display in Form1 Textbox? Pin
Zar Ni25-Oct-09 18:19
Zar Ni25-Oct-09 18:19 
QuestionThread Safe Form Controls Pin
FJJCENTU25-Oct-09 12:15
FJJCENTU25-Oct-09 12:15 
AnswerRe: Thread Safe Form Controls Pin
Luc Pattyn25-Oct-09 12:25
sitebuilderLuc Pattyn25-Oct-09 12:25 
GeneralRe: Thread Safe Form Controls Pin
FJJCENTU25-Oct-09 13:12
FJJCENTU25-Oct-09 13:12 
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 

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.