title: C# web browser history
body: <p>I'm developing a web browser in C# using Visual Studio 2017. I am trying to save the user's search history in a database and display it in a listbox. However, the database and listbox are empty. I have no idea why it's not working. 
  I have a bookmark button that works in the same way. It functions fine. The bookmarks show up in the listbox. 
  Any thoughts as to why the history listbox is always empty?</p>
  
  <pre><code>public class HistoryItem
  {
      public string URL { get; set; }
      public string Title { get; set; }
      public DateTime Date { get; set; }
      public int Id { get; set; }
  }
  
  public static void AddItem(HistoryItem item)
  {
      var adapter = new HistoryTableAdapter();
      adapter.Insert(item.URL, item.Title, item.Date.ToShortDateString());
  }
  
  public static List&lt;HistoryItem&gt; GetItems()
  {
      var adapter = new HistoryTableAdapter();
      var results = new List&lt;HistoryItem&gt;();
      var rows = adapter.GetData();
      foreach (var row in rows)
      {
          var item = new HistoryItem();
          item.URL = row.URL;
          item.Title = row.Title;
          item.Date = DateTime.Parse(row.Date);
          item.Id = row.Id;
          results.Add(item);
      }
      return results;
  }
  
  private void DisplayLabel(object sender, WebBrowserDocumentCompletedEventArgs e)
  {
      toolStripStatusLabel1.Text = "Done";
      toolStripProgressBar1.Value = 0;
      var item = new HistoryItem();
      item.URL = toolStripTextBox1.Text;
      item.Title = webBrowser1.DocumentTitle;
      item.Date = DateTime.Now;
      HistoryManager.AddItem(item);
  }
  
  private void HistoryManager_Load(object sender, EventArts e)
  {
      var items = HistoryManager.GetItems();
      foreach (var item in items)
      {
          HistoryListBox.Items.Add(string.Format("{0} ({1}) [{2}]", item.Title, item.URL, item.Date));
      }
  }
  </code></pre>