다음을 통해 공유


방법: Windows Forms ListView 컨트롤을 사용하여 항목 추가 및 제거

업데이트: 2007년 11월

Windows Forms ListView 컨트롤에 항목을 추가하는 프로세스는 주로 항목을 지정하고 이 항목에 속성을 할당하는 프로세스로 구성됩니다. 언제든지 목록 항목을 추가하거나 제거할 수 있습니다.

프로그래밍 방식으로 항목을 추가하려면

  • Items 속성의 Add 메서드를 사용합니다.

    ' Adds a new item with ImageIndex 3
    ListView1.Items.Add("List item text", 3)
    
    
    // Adds a new item with ImageIndex 3
    listView1.Items.Add("List item text", 3);
    
    
    // Adds a new item with ImageIndex 3
    listView1.get_Items().Add("List item text", 3);
    
    

프로그래밍 방식으로 항목을 제거하려면

  • Items 속성의 RemoveAt 또는 Clear 메서드를 사용합니다. RemoveAt 메서드는 항목 하나를 제거하며 Clear 메서드는 목록에 있는 항목을 모두 제거합니다.

    ' Removes the first item in the list.
    ListView1.Items.RemoveAt(0)
    ' Clears all items:
    ListView1.Items.Clear()
    
    
    // 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.get_Items().RemoveAt(0);
    
    

참고 항목

참조

ListView 컨트롤 개요(Windows Forms)

ListView

기타 리소스

ListView 컨트롤(Windows Forms)