title: Convert DateTime String to Date-only when listing in comboBox
body: <p>I have a <code>dataGridView_flaggedComments</code> where there's a column called <code>Comments_Date</code> (which is in a format of <code>31/12/2014 01:10:11 PM</code>), I am adding the date portion to <code>comboBox_stockDates</code> and if there are a few same dates e.g. <code>31/12/2014</code>, I would only want it to appear once in <code>comboBox_stockDates</code>, not repeated.</p>
  
  <p>Here's my code, and it will list all the date&amp;time in each row, but not grabbing the date-only portion. Could anyone point out which part of my code should I correct? Or it would be great if there's guidance to it. I apologise if I overlooked any similar questions. Thank you very much!</p>
  
  <pre><code>private void PopulateStockDatesIndex()
  {
      comboBox_stockDates.Items.Clear();
      comboBox_stockDates.Items.Add("Choose to Filter");
      comboBox_stockDates.FormatString = "dd-MM-yyyy";
      DataView dataview_filterDate = (DataView)(dataGridView_flaggedComments.DataSource);
      foreach (DataRowView rowView in dataview_filterDate)
      {
          DataRow row = rowView.Row;
          for (int i = 0; i &lt; dataGridView_flaggedComments.Rows.Count - 1; i++)
          {
              if (dataGridView_flaggedComments.Rows[i].Cells["Comments_Date"].Value.ToString() != "")
              {
                  if (!comboBox_stockDates.Items.Contains(row[1].ToString()))
                  {
                      comboBox_stockDates.Items.Add(row[1].ToString());
                  }
                  comboBox_stockDates.SelectedIndex = 0;
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>2nd version</strong>:</p>
  
  <pre><code>private void PopulateStockDatesIndex()
  {
      comboBox_stockDates.Items.Clear();
      comboBox_stockDates.Items.Add("Choose to Filter");
      comboBox_stockDates.FormatString = "dd-MM-yyyy";
  
      foreach (DataGridViewRow row in dataGridView_flaggedComments.Rows)
      {
          for (int i = 0; i &lt; dataGridView_flaggedComments.Rows.Count - 1; i++)
          {
              if (dataGridView_flaggedComments.Rows[i].Cells["Comments_Date"].Value.ToString() != "")
              {
                  string date = row.Field&lt;DateTime&gt;(1).ToString("dd-MM-yyyy");
                  if (!comboBox_stockDates.Items.Contains(date))
                  {
                      comboBox_stockDates.Items.Add(date);
  
                  }
                  comboBox_stockDates.SelectedIndex = 0;
              }
          }
      }
  }
  </code></pre>