How to: Add and Remove Items with the Windows Forms ListView Control
- Bài viết
- 09/01/2020
- 2 phút để đọc
-
-
Trang này có hữu ích không?
Vui lòng đánh giá trải nghiệm của bạn
Có
Không
Bạn còn phản hồi nào nữa không?
Ý kiến phản hồi sẽ được gửi đến Microsoft: Bằng cách nhấn nút gửi, ý kiến phản hồi của bạn sẽ được sử dụng để cải thiện các sản phẩm và dịch vụ của Microsoft. Chính sách về quyền riêng tư.
Gửi
Cảm ơn bạn.
Trong bài viết này
The process of adding an item to a Windows Forms ListView control consists primarily of specifying the item and assigning properties to it. Adding or removing list items can be done at any time.
To add items programmatically
Use the Add method of the Items property.
To remove items programmatically
Use the RemoveAt or Clear method of the Items property. The RemoveAt method removes a single item; the Clear method removes all items from the list.
// Removes the first item in the list. listView1.Items.RemoveAt[0]; // Clears all the items. listView1.Items.Clear[]; ' Removes the first item in the list. ListView1.Items.RemoveAt[0] ' Clears all items: ListView1.Items.Clear[]
See also
- ListView
- ListView Control
- ListView Control Overview