ListBox.EndUpdate() : ListBox « System.Windows.Forms « C# / C Sharp by API






ListBox.EndUpdate()

 
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

public class ListBoxItemAddRange : Form{
  ListBox lb;

  public ListBoxItemAddRange()
  {
    Size = new Size(300,400);

    lb = new ListBox();
    lb.Parent = this;
    lb.Location = new Point(10,10);
    lb.Size = new Size(ClientSize.Width - 20, Height - 200);
    lb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
    lb.BorderStyle = BorderStyle.Fixed3D;


    lb.BeginUpdate();
    string[] arNames = new string[5];
    for(int i = 0;i<5;i++){
       arNames[i] = "I";    
    }
    lb.Items.AddRange(arNames);

    lb.Items.Add("12345");
    lb.Items.Add("67890");
    lb.EndUpdate();
  } 

  static void Main() 
  {
    Application.Run(new ListBoxItemAddRange());
  }
}

   
  








Related examples in the same category

1.ListBox.BeginUpdate()
2.ListBox.ContextMenu
3.ListBox.DataBindings
4.ListBox.DataSource
5.ListBox.DataSourceChanged
6.ListBox.DisplayMember
7.ListBox.DisplayMemberChanged
8.ListBox.FindString
9.ListBox.Items
10.ListBox.Items.Add
11.ListBox.Items.AddRange
12.ListBox.Items.Clear()
13.ListBox.Items.RemoveAt
14.ListBox.ScrollAlwaysVisible
15.ListBox.SelectedIndex
16.ListBox.SelectedIndexChanged
17.ListBox.SelectedValueChanged
18.ListBox.SelectionMode
19.ListBox.TopIndex
20.ListBox.ValueMemberChanged