TAILIEUCHUNG - Visual Basic .NET at Work Building 10 Enterprise Projects phần 6

Cách tốt hơn để kết hợp các hình thức này vào chương trình của bạn là để xây dựng một thư viện lớp có chứa chúng. Không biết bạn có thể làm điều đó, bạn có? WinForms chỉ là các lớp học như bất cứ điều gì khác Bạn sẽ phải làm điều đó thông qua tài sản hoặc trong mã. | 238 Project 6 And here s the event trap for the ButtonColumn that gets us there Private Sub dgUsers_ItemCommand ByVal source As Object _ ByVal e As _ Handles If EditUser Then Dim li As ListItem False True 0 .Text 2 .Text 3 .Text 4 .Text BindDepartmentList For Each li In If 6 .Text Then True Exit For End If Next End If End Sub Let s first pick apart the method footprint. This is similar to the event trap footprint we ve worked with so far but the second parameter is not of type EventArgs. In this case it s DataGridCommandEventArgs. This is a class that inherits from and extends EventArgs. The inheritance provides type and functional support for all the portions of the Framework that deal with post backs generically. The extension allows the data grid to add some additional information to the type that is specific to the event it is raising. This is like COM object which supports more than one interface but it s even better than that because this extended type has the same interface as the original EventArgs class and all of the functionality as well. This means that when the creator of the data grid control needed the built-in functionality of the EventArgs class they got it free and had only to add a couple properties to create the additional functionality. The other difference in the footprint is the addition of the Handles keyword at the end. This is one way to set up an event trap in the .NET Framework. When the data grid control raises this event via a post back the Framework knows automatically to call this routine to handle the event because quite simply we ve told the Framework as much by saying it handles the ItemCommand event of the dgUsers DataGrid control. We ll take a

TỪ KHÓA LIÊN QUAN
Đã 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.