Manning Windows Forms Programming (phần 2)

Tham khảo tài liệu 'manning windows forms programming (phần 2)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Alternatively an alias for a specific type can be created. For example a shortcut for the Application class can be defined with using MyAppAlias This would permit the following line in your code new MyForm Typically the using directive simply indicates the namespaces employed by the program and this is how we use this directive in our program. For example rather than the fully qualified names and we simply use the Button and PictureBox names directly. It is worth noting that there is also a Button class in the namespace. The compiler uses the correct . class because of the using keyword and because the namespace is not referenced by our program. When we look at Visual Studio .NET in chapter 2 you will see that Visual Studio tends to use the fully qualified names everywhere. This is a good practice for a tool that generates code to guarantee that any potential for ambiguity is avoided. Fields and properties Let s go back to our use of the Button and PictureBox classes. The top of our class now defines two member variables or fields in C to represent the button and the picture box on our form. Here Button and PictureBox are classes in the Windows Forms namespace that are used to create a button and picture box control on a Form. We will tend to use the terms class and control interchangeably for user interface objects in this public class MyForm Form private Button btnLoad private PictureBox pboxPhoto Fields like all types in C must be initialized before they are used. This initialization occurs in the constructor for the MyForm class. public MyForm Create and configure the Button btnLoad new Button Load 10 10 3 Or more formally we will use the term control to refer to an instance of any class derived from the Control class in the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.