ToolStripComboBox.BeginUpdate 方法


當項目一次一筆加入 ToolStripComboBox 時可維護效能。Maintains performance when items are added to the ToolStripComboBox one at a time.

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


這個方法會防止控制項繪製,直到呼叫 EndUpdate 方法為止。This method prevents the control from painting until the EndUpdate method is called.

將專案加入至 ToolStripComboBox 的慣用方式,是透過 ToolStripComboBoxItems 屬性來使用 AddRange 方法。The preferred way to add items to the ToolStripComboBox is to use the AddRange method through the Items property of the ToolStripComboBox. 這可讓您一次將一個專案陣列加入清單中。This enables you to add an array of items to the list at one time. 不過,如果您想要使用 Add 方法一次加入一個專案,您可以使用 BeginUpdate 方法,在每次將專案新增至清單時,防止控制項重新繪製 ToolStripComboBoxHowever, if you want to add items one at a time using the Add method, you can use the BeginUpdate method to prevent the control from repainting the ToolStripComboBox each time an item is added to the list. 完成將專案新增至清單的工作之後,請呼叫 EndUpdate 方法,讓 ToolStripComboBox 重新繪製。Once you have completed the task of adding items to the list, call the EndUpdate method to enable the ToolStripComboBox to repaint. 這種新增專案的方式可在將大量專案新增至清單時,防止 ToolStripComboBox 繪製期間發生閃爍。This way of adding items can prevent flicker during the drawing of the ToolStripComboBox when a large number of items are being added to the list.