Đang chuẩn bị liên kết để tải về tài liệu:
Beginning microsoft Visual Basic 2010 phần 7

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Khởi động dự án. Bây giờ bạn sẽ thấy rằng khi một URL được chọn từ danh sách, LinkLabel kiểm soát thay đổi để phản ánh tên của mục đã chọn (xem hình 12-4). Khi bạn nhấp vào liên kết, Internet Explorer sẽ mở ra địa chỉ URL trong LinkCollection kiểm soát LinkLabel. | 398 I CHAPTER 12 ADVANCED OBJECT-ORIENTED TECHNIQUES ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs _ Handles lnkUrl.LinkClicked Process the selected link Process.Start e.Link.LinkData End Sub 3. Run the project. You should now see that when a URL is selected from the list the LinkLabel control changes to reflect the name of the selected item refer to Figure 12-4 . When you click the link Internet Explorer opens the URL in the LinkLabel control s LinkCollection. How It Works Now that you have the application working in this example let s look at how it works. When you click an item in the ListView control the Click event is fired for that control. You add code to the Click event to load the LinkLabel control with the selected link. You start by first setting the Text property of the LinkLabel control. This is the text that will be displayed on the form as shown in Figure 12-4. You set the Text property using the static text Visit followed by the actual favorite name. The favorite name is retrieved from the ListView control s Item collection. Each row in the ListView control is called an item and the first column contains the text of the item. Each column past the first column in a row is a subitem of the item the text in the first column . The text that gets displayed in the link label is taken from the Text property of the Item collection Private Sub lvwFavorites_Click ByVal sender As Object _ ByVal e As System.EventArgs Handles lvwFavorites.Click Update the link label control Text property lnkUrl.Text Visit lvwFavorites.SelectedItems.Item 0 .Text The Links property of the LinkLabel control contains a LinkCollection that contains a default hyperlink consisting of the text that is displayed in the LinkLabel control. You clear this collection and set it using the correct hyperlink for the selected Favorite. You do this by calling the Clear method on the Links property Clear the default hyperlink lnkUrl.Links.Clear Finally you add your hyperlink using

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.