ListBox.EndUpdate Yöntem

Tanım

Boyama ListBox yöntemiyle askıya alındıktan sonra denetimi boyamaya devam eder BeginUpdate() .

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

Örnekler

Aşağıdaki kod örneği, öğesine beş bin öğe BeginUpdateeklerken ve EndUpdate yöntemlerini kullanırListBox. Bu örnek, adlı ListBoxbir listBox1 denetimin öğesine eklenmesini Form ve bu yöntemin forma yerleştirilmesini ve ondan çağrıldığını gerektirir.

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

Açıklamalar

öğesine öğe ListBox eklemenin tercih edilen yolu sınıfının yöntemini AddRange kullanmaktır ListBox.ObjectCollection (özelliği ItemsaracılığıylaListBox). Bu, listeye bir kerede bir öğe dizisi eklemenize olanak tanır. Ancak, sınıfın Add yöntemini ListBox.ObjectCollection kullanarak öğeleri birer birer eklemek istiyorsanız, bir öğe listeye her eklendiğinde denetimin yeniden boyanmasını BeginUpdate önlemek için yöntemini kullanabilirsinizListBox. Listeye öğe ekleme görevini tamamladıktan sonra, öğesinin EndUpdate yeniden boyanmasını sağlamak ListBox için yöntemini çağırın. Bu öğe ekleme yöntemi, listeye çok sayıda öğe eklendiğinde öğesinin titreşen çizimini ListBox engelleyebilir.

Şunlara uygulanır

Ayrıca bkz.