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:
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();
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. |