Demonstrations

 

One-Way Communication: Using Arguments

There is a second way to pass information from the main window to the child window. This is called one-way communication, and it uses arguments. Most programmers are familiar with this method because it was invented in the 1960s. Here is how it works:

  1. Place arguments into the Form2 creation statement (from Form1):

     //   Create the Form2 modal window. //   Send 3 arguments to Form2: int, char, string. Form2 frm2 = new Form2(kkForm1, intWeek, intYear); frm2.ShowDialog(); frm2.Close(); 
  2. Receive the arguments in Form2:

     public Form2(int TNumber1, int TNumber2, int TNumber3) {   FileNumber = TNumber1;   iWeek = TNumber2;   iYear = TNumber3; 

The only data types you can pass this way are the integer, float, double, and decimal. Character and string arrays cannot be sent or received.

Note  

If things go badly for you during this build of OverTheRiverAndThroughTheWoods, you will find a complete copy of the project in Visual Studio 2005\Projects\DemosSourceCode if you copied all the demo code from the companion files to your PC hard drive as described in the Introduction.

 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net