ListBox.EndUpdate メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


ListBox に項目を追加するには、ListBox の Items プロパティを使用してアクセスする ListBox.ObjectCollection クラスの AddRange メソッドを使用する方法をお勧めします。これにより、項目の配列をリストに一度に追加できます。しかし、ListBox.ObjectCollection クラスの Add メソッドを使用して 1 つずつ項目を追加する場合は、BeginUpdate メソッドを使用して、項目がリストに追加されるたびに ListBox が再描画されるという状況を回避できます。項目をリストに追加するタスクが完了した後で、EndUpdate メソッドを呼び出して ListBox を再描画できるようにします。リストに多数の項目を追加する場合は、この方法で項目を追加すると、ListBox を描画するときにちらつきません。

5,000 の項目を ListBox に追加するときに、BeginUpdate メソッドと EndUpdate メソッドを使用するコード例を次に示します。この例では、listBox1 という名前の ListBox コントロールが Form に追加されており、このメソッドがそのフォーム内に含まれ、そこから呼び出される必要があります。
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
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(); }
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.get_Items().Add(("Item" + (new Integer(x)).ToString())); } // End the update process and force a repaint of the ListBox. listBox1.EndUpdate(); } //AddToMyListBox
function AddToMyListBox(){ // Stop the ListBox from drawing while items are added. listBox1.BeginUpdate() // Loop through and add five thousand new items. for(var x = 0; x < 5000; x++) listBox1.Items.Add("Item " + x.ToString()) // End the update process and force a repaint of the ListBox. listBox1.EndUpdate() }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からListBox.EndUpdate メソッドを検索する場合は、下記のリンクをクリックしてください。

- ListBox.EndUpdate メソッドのページへのリンク