Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
ComboBox Class
ComboBox Methods
 EndUpdate Method

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ComboBox..::.EndUpdate Method

Resumes painting the ComboBox control after painting is suspended by the BeginUpdate method.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Visual Basic (Declaration)
Public Sub EndUpdate
Visual Basic (Usage)
Dim instance As ComboBox

instance.EndUpdate()
C#
public void EndUpdate()
Visual C++
public:
void EndUpdate()
JScript
public function EndUpdate()

The preferred way to add items to the ComboBox is to use the AddRange method of the ComboBox..::.ObjectCollection class (through the Items property of the ComboBox). This enables you to add an array of items to the list at one time. However, if you want to add items one at a time using the Add method of the ComboBox..::.ObjectCollection class, you can use the BeginUpdate method to prevent the control from repainting the ComboBox each time an item is added to the list. Once you have completed the task of adding items to the list, call the EndUpdate method to enable the ComboBox to repaint. This way of adding items can prevent flickered drawing of the ComboBox when a large number of items are being added to the list.

The following code example shows the usage of the BeginUpdate and EndUpdate methods. The example is part of a code example in the ComboBox class overview.

Visual Basic
Private Sub addGrandButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    comboBox1.BeginUpdate()
    Dim I As Integer
    For I = 0 To 1000
        comboBox1.Items.Add("New Item " + i.ToString())
    Next
    comboBox1.EndUpdate()
End Sub

C#
private void addGrandButton_Click(object sender, System.EventArgs e) {
    comboBox1.BeginUpdate();
    for (int i = 0; i < 1000; i++) {
        comboBox1.Items.Add("New Item " + i.ToString());
    }
    comboBox1.EndUpdate();
}

Visual C++
void addGrandButton_Click( Object^ sender, System::EventArgs^ e )
{
   comboBox1->BeginUpdate();
   for ( int i = 0; i < 1000; i++ )
   {
      comboBox1->Items->Add( "New Item " + i.ToString() );
   }
   comboBox1->EndUpdate();
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker