title: Adding generic list items to Winforms' listbox c#
body: <p>Hi Im trying to add the items to a generic list. Then on a button click the generic list items should be transferred to my listbox1. This works however, it keeps adding them every time I click the button.</p>
  
  <p>I tried using an if command, 
  sometime like this</p>
  
  <pre><code> if (listBox1.Items.Count == 0)
   {
       // this contained everything I am now adding under initialize component)
   }
  </code></pre>
  
  <p>But this generated the error. index value can not be 0.
  So in essence this works as is. But I do not want keep adding the items every time I click.</p>
  
  <pre><code>public Form1()
  {
      InitializeComponent();
      list.Add("Januari");
      list.Add("Februari");
      list.Add("March");
      list.Add("April");
      list.Add("May");
      list.Add("June");
      list.Add("July");
      list.Add("August");
      list.Add("September");
      list.Add("Oktober");
      list.Add("November");
      list.Add("December");
  }
  
  private IList&lt;string&gt; list = new List&lt;string&gt;();
  
  private void button1_Click(object sender, EventArgs e)
  {
      for (int index = 0; index &lt; list.Count; index++)
      {
          listBox1.Items.Add(list[index]);
      }
  
      int mnr = Convert.ToInt32(textBox1.Text);
      string mnm = Convert.ToString(listBox1.Items[mnr - 1]);
      textBox2.Text = mnm;      
  }
  </code></pre>