C# - Auto refresh a ListView
<p>I have a <code>ListView</code> and the <code>ListView</code> data is taken from database.
Beside the <code>ListView</code> got a button to add the record.</p>

<p>if the button is pressed it will show a dialog</p>

<p>Code :</p>

<pre><code>private void bAddStudent_Click(object sender, EventArgs e) {
    fAddStudent addStudent = new fAddStudent();
    addStudent.ShowDialog();
}
</code></pre>

<p>After add the record, the dialog will <code>close()</code> and show the ListView. 
But the <code>ListView</code> is not update the data.</p>

<p>Is there any way to make it <strong>auto update</strong>?</p>

<p><strong>Edit :</strong> 
Here is how I add records :</p>

<pre><code>private void btnAdd_Click(object sender, EventArgs e) {
    string studentID = tbStudentId.Text;
    string studentName = tbStudentName.Text;
    string gender = tbGender.Text;

    string connectionString = "Data Source=xxx\\SQLEXPRESS;Initial Catalog=TestApplication;Integrated Security=SSPI; User ID=xxx;Password=xxx";

    using (SqlConnection connection = new SqlConnection(connectionString)) {
        SqlCommand cmd = new SqlCommand("INSERT INTO student (student_id, student_name, student_gender) VALUES (@studentId, @studentname, @studentGender) ");
        cmd.CommandType = CommandType.Text;
        cmd.Connection = connection;
        cmd.Parameters.AddWithValue("@studentId", studentID);
        cmd.Parameters.AddWithValue("@studentName", studentName);
        cmd.Parameters.AddWithValue("@studentGender", gender);
        connection.Open();
        cmd.ExecuteNonQuery();
    }
}
</code></pre>

<p>Code For showing <code>ListView</code> :</p>

<pre><code>List&lt;string&gt; myListHeader = new List&lt;string&gt;(new string[] { "ID", "Name", "Gender" });
myListHeader.ForEach(name =&gt; lvStudent.Columns.Add(name));

SqlConnection UGIcon = new SqlConnection();
UGIcon.ConnectionString = "Data Source=xxx\\SQLEXPRESS;Initial Catalog=TestApplication;Integrated Security=SSPI; User ID=xxx\\user;Password=xxx";
UGIcon.Open();

SqlCommand cmd = new SqlCommand("SELECT * FROM student", UGIcon);

SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read()) {
    ListViewItem item = new ListViewItem(dr[0].ToString());
    item.SubItems.Add(dr[1].ToString());
    item.SubItems.Add(dr[2].ToString());
    lvStudent.Items.Add(item);
}
</code></pre>

<p><strong>Note</strong></p>

<p><strong>'Add data' form is different with showing the <code>ListView</code> form, so I cannot access the <code>ListView</code> in the 'add data' form</strong></p>
