Visual Basic .NET at Work Building 10 Enterprise Projects phần 2

Bây giờ bạn có thể thêm bất kỳ hình thức nào bạn thích dựa trên các hình thức mà bạn chỉ cần nạp. Ví dụ, chúng ta sẽ tạo ra một hình thức dựa trên hình thức frmBase. Nhấp chuột phải vào tên dự án trong giao diện dự án và chọn Add / Thêm mẫu thừa kế. | 30 Project 1 Now you can add any forms you like based on the forms you just loaded. As an example we will create a form based on the frmBase form. Right-click on the project name in the Project view and select Add Add Inherited Form. Type in a name for the form and then click Open. On the next window as in Figure select the form from which you want to inherit. Select the frmBase form and click OK. Now you have an inherited form in your program. Even though you haven t done anything to it yet you ll see that the form has all the controls from the base form already in place. One important point to note here is that the controls from the base form are locked and cannot be edited in the Form Designer. You ll have to do it through properties or in code. Creating a Class Library The better way to incorporate these forms into your program is to build a class library that contains them. Didn t know you could do that did you WinForms are just classes like anything else now. We can place them in a DLL and use them in other programs. Here s the easy way to do it. Create a new Class Library project in Visual Studio. Name it prj01classes. When the project creation is complete delete the default class Class1 from the project and add the form files to the project. Right-click on the solution name in the solution explorer and from the context menu select Add Existing Item. Select all the form .VB and .RESX files and add them to the project. Build the project. When you re done you ll have a DLL you can add to any project. Want to try it out Create a new WinForms project naming it whatever you like. Right-click on the References section in Solution Explorer and from the context menu select Add Reference. In the dialog that appears click the Browse button and find the DLL we just created select it and click OK. Click OK on the original dialog. Now you can add a new inherited form to the project. When the Inherited Form dialog appears type in a new name for the form and click .

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.