title: Clear ListView items and update from second form
body: <p>I have  <code>ListView</code> (SessionList) in my main form (<code>Form1</code>). And I'm listing items by getting value form mysql database by calling the function <code>CreateSessionList()</code> in <code>Form1_Load()</code>.</p>
  
  <p>Now I want to filter. So, I have another form (FilterForm) invoked by using the menu from main form (Form1).</p>
  
  <p><code>FilterForm</code> contains a <code>ComboBox</code> for all column header of particular table.
  When I click the <strong>Filter</strong> button in second Form(Filter Form), I'm sending the selected data to first form(Form1), there I clear all previous items in List view and by having this new data for SELECT query to display new data in <code>ListView</code>.</p>
  
  <p>What happened here is, previous list is not get cleared. It shows the count as zero. but View has the old data. No change at all.</p>
  
  <p>Form1.cs  Coding</p>
  
  <pre><code>private void CreateSessionList()
          {
  
              SessionList.View = View.Details;          
              SessionList.Items.Clear();         
              MySqlDataAdapter ada = new MySqlDataAdapter("SELECT * FROM sessiontbl", Properties.Settings.Default.DBPerfScoreConnectionString);            
              DataTable dt = new DataTable();
              ada.Fill(dt);
              for (int i = 0; i &lt; dt.Rows.Count; i++)
              {
                  DataRow dr = dt.Rows[i];
                  ListViewItem listitem = new ListViewItem((i+1).ToString());               
                  listitem.SubItems.Add(dr["SessionID"].ToString());
                  listitem.SubItems.Add(dr["InstID"].ToString());
                  listitem.SubItems.Add(dr["Trainee"].ToString());
                  listitem.SubItems.Add(dr["SessDt"].ToString());
                  listitem.SubItems.Add(dr["ModelID"].ToString());
                  listitem.SubItems.Add(dr["ModelName"].ToString());
                  listitem.SubItems.Add("Alarm"); 
                  SessionList.Items.Add(listitem);                
              } 
          }
  
  public void GetWhereQuery(String Sesssel, String Inssel, String Trsel, String Modsel, String Dtsel)
          {
              SessionList.Items.Clear(); //After this,item count shows 0
              SessionList.Refresh();
  
              String sQuery = "SELECT * FROM sessiontbl WHERE (SessionID ='"+ Sesssel+"')";
              MySqlDataAdapter ada = new MySqlDataAdapter(sQuery, Properties.Settings.Default.DBPerfScoreConnectionString);
              DataTable dt = new DataTable();
              ada.Fill(dt);
              for (int i = 0; i &lt; dt.Rows.Count; i++)
              {
                  DataRow dr = dt.Rows[i];
                  ListViewItem listitem = new ListViewItem((i + 1).ToString());
                  listitem.SubItems.Add(dr["SessionID"].ToString());
                  listitem.SubItems.Add(dr["InstID"].ToString());
                  listitem.SubItems.Add(dr["Trainee"].ToString());
                  listitem.SubItems.Add(dr["SessDt"].ToString());
                  listitem.SubItems.Add(dr["ModelID"].ToString());
                  listitem.SubItems.Add(dr["ModelName"].ToString());
                  listitem.SubItems.Add("Alarm");
                  SessionList.Items.Add(listitem);
              } 
  
          }
  </code></pre>
  
  <p>FilterForm.cs Coding</p>
  
  <pre><code>private void Filterbtn_Click(object sender, EventArgs e)
          {            
  
              if(sessioncombo.SelectedIndex&gt;-1)
                   Sesssel = sessioncombo.SelectedItem.ToString();
              if(InstructorCombo.SelectedIndex&gt;-1)
                   Inssel = InstructorCombo.SelectedItem.ToString();
              if(TraineeCombo.SelectedIndex&gt;-1)
                   Trsel = TraineeCombo.SelectedItem.ToString();
              if(ModelCombo.SelectedIndex&gt;-1)
                   Modsel = ModelCombo.SelectedItem.ToString();
              if(Datecombo.SelectedIndex&gt;-1)
                   Dtsel = Datecombo.SelectedItem.ToString();
              frm = new Form1();
              frm.GetWhereQuery(Sesssel, Inssel, Trsel, Modsel, Dtsel); //Calling function of form1 to filter.
              this.Close();
  
  
          }
  </code></pre>