title: C# - Selecting multiple items in a ListBox and converting into a comma separated string in Windows Form
body: <p>I'm building a GUI to update a database with values from a listbox. I've already connected to the server and database, and I have it putting information into the correct columns. I just can't get it to display the multiple values that I select. I'm pretty new to this.</p>
  
  <pre><code>string colors = "";
  StringBuilder sb = new StringBuilder();
  foreach (var items in listboxColor.SelectedItems)
  {
   sb.Append(listboxColor.SelectedItem + ", ");
  } 
  colors = sb.ToString();
  </code></pre>
  
  <hr>
  
  <p>This is an example:</p>
  
  <pre><code>Example ListBox (** is the selected item)
  **Red**
  Blue
  **Green**
  Yellow
  Orange
  **Purple**
  --------------------------
  Output:
  Red, Red, Red
  </code></pre>
  
  <p>I want it to be like this:</p>
  
  <pre><code>Output:
  Red, Green, Purple
  </code></pre>
  
  <p>Thank you! If you need more info, let me know please.</p>