Click here to Skip to main content
15,891,905 members
Home / Discussions / C#
   

C#

 
GeneralKey accelerator Pin
BoudewijnEctor13-Apr-03 2:22
BoudewijnEctor13-Apr-03 2:22 
GeneralLAN chat program Pin
BoudewijnEctor13-Apr-03 2:18
BoudewijnEctor13-Apr-03 2:18 
GeneralRe: LAN chat program Pin
Mazdak13-Apr-03 9:55
Mazdak13-Apr-03 9:55 
GeneralRe: LAN chat program Pin
Tolulope Delight4-Jun-10 4:36
Tolulope Delight4-Jun-10 4:36 
GeneralMultiple Forms Pin
BoudewijnEctor13-Apr-03 2:11
BoudewijnEctor13-Apr-03 2:11 
GeneralRe: Multiple Forms Pin
moredip13-Apr-03 2:44
moredip13-Apr-03 2:44 
GeneralRe: Multiple Forms Pin
BoudewijnEctor14-Apr-03 8:35
BoudewijnEctor14-Apr-03 8:35 
GeneralRe: Multiple Forms Pin
moredip14-Apr-03 11:46
moredip14-Apr-03 11:46 
Sounds like a candidate for events. Basically form2 'publishes' a 'FormChanged' event, and then form1 'subscribes' to that event.

If you haven't dealt with events and delegates in C# before, be warned: it can be confusing at first Hmmm | :| MSDN and CodeProject articles will explain it a lot better than I can..

That said, you'll want something along the lines of:
public class form2 : Form
{
   //publish a FormChanged event
   public event EventHandler FormChanged;
   ...
   ...
   protected void SomeClassThatChangesForm2()
   {
   ...
   ...
      //we just did something that changed this form, so
      //we'll fire the FormChanged event to inform subscribers
      if( FormChanged != null ) //if we have subscribers
         FormChanged( this, new EventArgs() ) //fire the event
   ...
   }
   ...
}

public class form1 : Form
{
   ...
   ...
   protected void Form2ChangedHandler( object sender, EventArgs e )
   {
      //if we are in this handler, it means that we've 
      //recieved the FormChanged event 
      ...
      //deal with the event
      ...
   }
   ...
   ...
   //constructor
   public form1()
   {
      ...
      //subscribe to form2's event, specifying the handler
      //as the protected Form2ChangedHandler method
      this.form2.FormChanged += 
         new EventHandler( Form2ChangedHandler );
      ...
   }
   ...
}



Does that make any sense at all to you Smile | :)

Hope it's helped a little,

Pete
QuestionWhat's up with User Controls? Pin
Dave Kerr13-Apr-03 0:54
Dave Kerr13-Apr-03 0:54 
AnswerRe: What's up with User Controls? Pin
Danny Blanchard13-Apr-03 20:19
Danny Blanchard13-Apr-03 20:19 
AnswerRe: What's up with User Controls? Pin
Martin Cook15-Apr-03 8:33
professionalMartin Cook15-Apr-03 8:33 
GeneralOne more question on web services Pin
Cristoff13-Apr-03 0:47
Cristoff13-Apr-03 0:47 
GeneralRe: One more question on web services Pin
moredip13-Apr-03 2:49
moredip13-Apr-03 2:49 
GeneralA simple property question Pin
kensai12-Apr-03 23:57
kensai12-Apr-03 23:57 
GeneralRe: A simple property question Pin
Dave Kerr13-Apr-03 1:03
Dave Kerr13-Apr-03 1:03 
GeneralRe: A simple property question Pin
kensai14-Apr-03 9:50
kensai14-Apr-03 9:50 
GeneralRe: A simple property question Pin
Anonymous23-Apr-03 10:02
Anonymous23-Apr-03 10:02 
GeneralListview and database Pin
fredza12-Apr-03 21:48
fredza12-Apr-03 21:48 
GeneralRe: Listview and database Pin
Stephane Rodriguez.12-Apr-03 22:11
Stephane Rodriguez.12-Apr-03 22:11 
Generaluint.Parse() vs. Convert.ToUint32() Pin
moredip12-Apr-03 14:48
moredip12-Apr-03 14:48 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
Stephane Rodriguez.12-Apr-03 21:10
Stephane Rodriguez.12-Apr-03 21:10 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
moredip13-Apr-03 0:38
moredip13-Apr-03 0:38 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
Stephane Rodriguez.13-Apr-03 1:15
Stephane Rodriguez.13-Apr-03 1:15 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
moredip13-Apr-03 1:23
moredip13-Apr-03 1:23 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
leppie13-Apr-03 3:00
leppie13-Apr-03 3:00 

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.