TAILIEUCHUNG - Design View Main

changes in the Design View. Any code that you need to write yourself should be placed in the file. At this point you might well be wondering where the Main method is and how the form gets displayed when the application runs; remember that Main defines the point at which the program starts. In the Solution Explorer, you should notice another source file called . | changes in the Design View. Any code that you need to write yourself should be placed in the file. At this point you might well be wondering where the Main method is and how the form gets displayed when the application runs remember that Main defines the point at which the program starts. In the Solution Explorer you should notice another source file called . If you double-click this file the following code appears in the Code and Text Editor window namespace WinFormHello static class Program summary The main entry point for the application. summary STAThread static void Main new Form1 You can ignore most of this code. However the key statement is new Form1 This statement creates the form and displays it whereupon the form takes over. In the following exercise you ll learn how to add code that runs when the OK button on the form is clicked. Write the code for the OK button 1. Click the Design tab above the Code and Text Editor window to display Form1 in the Design View. 2. Move the mouse pointer over the OK button on the form and then double-click the button. The source file appears in the Code and Text Editor window. Visual Studio 2005 has added a method called ok_Click to the Form1 class. It has also added a statement to the InitializeComponent method in the file to automatically call ok_Click when the OK button is clicked. It does this by using a delegate type delegates are discussed in Chapter 16 Delegates and Events. 3. Type the MessageBox statement shown below inside the ok_Click method. The complete method should look like this 4. private void ok_Click object sender e 5. 6. Hello Make sure you have typed this code exactly as shown including the trailing semicolon. You re now ready to run your first Windows program. Run the Windows program 1. On the Debug menu click Start Without Debugging. Visual

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.