ListBox.EndUpdate 메서드

정의

ListBox 메서드에 의해 그리기가 일시 중단된 후 BeginUpdate() 컨트롤 그리기를 다시 시작합니다.

public:
 void EndUpdate();
public void EndUpdate ();
member this.EndUpdate : unit -> unit
Public Sub EndUpdate ()

예제

다음 코드 예제에서는 5,000개의 항목을 추가하는 동안 및 EndUpdate 메서드를 ListBox사용합니다BeginUpdate. 이 예제에서는 명명listBox1ListBox 컨트롤이 a Form 에 추가되고 이 메서드가 폼 내에 배치되고 해당 컨트롤에서 호출되어야 합니다.

void AddToMyListBox()
{
   // Stop the ListBox from drawing while items are added.
   listBox1->BeginUpdate();

   // Loop through and add five thousand new items.
   for ( int x = 1; x < 5000; x++ )
   {
      listBox1->Items->Add( String::Format( "Item {0}", x ) );
   }
   listBox1->EndUpdate();
}
public void AddToMyListBox()
{
   // Stop the ListBox from drawing while items are added.
   listBox1.BeginUpdate();

   // Loop through and add five thousand new items.
   for(int x = 1; x < 5000; x++)
   {
      listBox1.Items.Add("Item " + x.ToString());   
   }
   // End the update process and force a repaint of the ListBox.
   listBox1.EndUpdate();
}
Public Sub AddToMyListBox()
    ' Stop the ListBox from drawing while items are added.
    listBox1.BeginUpdate()
       
    ' Loop through and add five thousand new items.
    Dim x As Integer
    For x = 1 To 4999
        listBox1.Items.Add("Item " & x.ToString())
    Next x
    ' End the update process and force a repaint of the ListBox.
    listBox1.EndUpdate()
End Sub

설명

항목을 ListBox 추가하는 기본 방법은 클래스의 ListBox.ObjectCollection 메서드를 사용하는 AddRange 것입니다(속성 사용 Items ListBox). 이렇게 하면 목록에 항목 배열을 한 번에 추가할 수 있습니다. 그러나 클래스의 ListBox.ObjectCollection 메서드를 사용하여 Add 항목을 한 번에 하나씩 추가하려는 경우 이 메서드를 사용하여 BeginUpdate 항목이 목록에 추가 될 때마다 컨트롤이 다시 표시되지 ListBox 않도록 할 수 있습니다. 목록에 항목을 추가하는 작업을 완료했으면 메서드를 호출 EndUpdate 하여 다시 칠할 수 있도록 합니다 ListBox . 이러한 방식으로 항목을 추가하면 목록에 많은 수의 항목이 ListBox 추가될 때 깜박이는 그리기를 방지할 수 있습니다.

적용 대상

추가 정보