A slightly more complex program typically has two or more forms. Sometimes in programming, data is passed not only in the same form, but also between forms, which are passed between the main form and the data from the form. Starting with this article, we'll enumerate four scenarios for data transfer between different forms, and how to implement these four scenarios with Visual C #. The first case of passing data between forms by using Visual C # is described below-passing strings from the main form to the form. After reading this article, you also try to use this method to transfer data between forms.
The software environment for programming, debugging and running in this paper:
Windows2000 Server Edition
Visual Studio.NET official edition,. Net FrameWork SDK version number 3705
Implementation steps:
1. Start visual Studio. Net
2. Select Menu "File" | "new" | "Project", pop-up "New Project" dialog box
3. Set "project type" to "Visual C # project"
4. Set "template" to "Console Application"
5. In the Name text box, enter the data delivery method for different forms in vc# 01
6. In the "Position" text box, enter "E:\VS." NET project, and then click the OK button so that the data delivery Method 01 project for different forms in vc# is created and completed
7. Switch the current window of Visual Studio.NET to the Form1.cs window, and drag the following components into the Form1.cs form from the Windows Forms tab in the Toolbox and perform the appropriate actions:
· Two textbox component for entering data sent to the Form2 form
· Two label components
· A button component with the name Button1 and, after dragging into the Form1.cs form, double-click it, Visual Stuido. NET produces the processing code corresponding to its click event.