title: C# Winforms - Databinding or List<T>
body: <p>I have here a method inside a class called PurchaseOrder. Here, I used <code>List&lt;string&gt;</code> to retrieve a list of suppliers and populate these lists in a combo box. The code actually works, but as I add more and more suppliers in my SQL Server database, I have been experiencing a little slowdown on the forms being loaded. How could I optimize such speed?</p>
  
  <p>Below are two sets of codes, the method PopulateSuppliers() from PurchaseOrderClass.cs and a Form_Load event.</p>
  
  <pre><code>    public object PopulateSuppliers()
      {
          //Create an instance of a List of Strings.
          List&lt;string&gt; ListOfSuppliers = new List&lt;string&gt;();
  
          string sqlString = "SELECT CompanyName FROM tbl_suppliers WHERE Archived = 'False';";
  
          SqlConnection sqlConnection = new SqlConnection(connectionString);
          SqlCommand sqlCommand = new SqlCommand(sqlString, sqlConnection);
  
          sqlConnection.Open();
          sqlReader = sqlCommand.ExecuteReader();
  
          while (sqlReader.Read())
          {
              ListOfSuppliers.Add(sqlReader["CompanyName"].ToString());
          }
  
          sqlReader.Close();
          sqlConnection.Close();
  
          return ListOfSuppliers;
      }
  
      private void frmPurchaseOrderEditor_Load(object sender, EventArgs e)
      {
          ...
  
          //Populate a list of suppliers.
          cboSuppliers.DataSource = PurchaseOrder.PopulateSuppliers();
  
          ...
      }
  </code></pre>