method ComboBox.BeginUpdate ()

Maintains performance when items are added to the control one at a time.

TypeDescription

This method prevents the control from painting until the EndUpdate method is called. The BeginUpdate and EndUpdate methods increases the speed of loading your items, by preventing painting the control when it suffers any change. 

The following VB sample uses the BeginUpdate and EndUpdate methods while loading columns from a recrodset:

Set rs = CreateObject("ADODB.Recordset")
rs.Open "Orders", "Provider=Microsoft.Jet.OLEDB.3.51;Data Source= D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB", 3 ' Opens the table using static mode

ComboBox1.BeginUpdate
For Each f In rs.Fields
    ComboBox1.Columns.Add f.Name
Next
ComboBox1.PutItems rs.GetRows()
ComboBox1.EndUpdate

The following VB sample prevents painting the control during loading columns and items:

With ComboBox1
    .BeginUpdate
    .Columns.Add ("Column 1")
    With .Items
        .AddItem "Item 1"
        .AddItem "Item 2"
    End With
    .EndUpdate
End With

The following C++ sample prevents painting the control during loading columns and items:

m_combobox.BeginUpdate();
CColumns columns = m_combobox.GetColumns();
columns.Add( "Column 1" );
CItems items = m_combobox.GetItems();
items.AddItem( COleVariant("Item 1") );
items.AddItem( COleVariant("Item 2") );
items.AddItem( COleVariant("Item 3") );
m_combobox.EndUpdate();

The following VB.NET sample prevents painting the control during loading columns and items:

With AxComboBox1
    .BeginUpdate()
    .Columns.Add("Column 1")
    With .Items
        .AddItem("Item 1")
        .AddItem("Item 2")
    End With
    .EndUpdate()
End With

The following C# sample prevents painting the control during loading columns and items:

axComboBox1.BeginUpdate();
axComboBox1.Columns.Add("Column 1");
axComboBox1.Items.AddItem("Item 1");
axComboBox1.Items.AddItem("Item 2");
axComboBox1.EndUpdate();

The following VFP sample prevents painting the control during loading columns and items:

With thisform.ComboBox1
    .BeginUpdate
    .Columns.Add ("Column 1")
    With .Items
        .AddItem("Item 1")
        .AddItem("Item 2")
    EndWith
    .EndUpdate
EndWith