how to refresh DataGridView after deleting a row form DataGridView and database in c#?
<p>after deleting a selected row of stockdataGridView1, It don't refresh. please tell me how to refresh after deleting selected row. do I need to reopen the form or add another button for refresh ?</p>

<pre><code>private void stockdataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{

}

private void Report_Load(object sender, EventArgs e)
{
    string connectionString = @"Server=.\SQLEXPRESS; Database = stock; integrated Security = true";
    SqlConnection connection = new SqlConnection(connectionString);
    string query = "SELECT * FROM stocktable1";
    SqlCommand command = new SqlCommand(query, connection);
    connection.Open();
    SqlDataReader reader = command.ExecuteReader();
    List&lt;Stock&gt; stocks = new List&lt;Stock&gt;();
    while (reader.Read())
    {
        Stock stock = new Stock();
        stock.id = (int)reader["id"];
        stock.gsm = reader["gsm"].ToString();
        stock.color = reader["color"].ToString();
        stock.size = reader["size"].ToString();
        stock.yard = reader["yard"].ToString();
        stock.meter = reader["meter"].ToString();
        stock.quantity = reader["quantity"].ToString();
        stock.supplier = reader["supplier"].ToString();
        stock.purpose = reader["purpose"].ToString();
        stock.chalanno = reader["chalanno"].ToString();
        stocks.Add(stock);
    }
    reader.Close();
    connection.Close();
    stockdataGridView1.DataSource = stocks;
}

private void deletebutton_Click(object sender, EventArgs e)
{

    int id = (int)stockdataGridView1.CurrentRow.Cells["id"].Value;
    string connectionString = @"Server=.\SQLEXPRESS; Database = stock; integrated Security = true";
    SqlConnection connection = new SqlConnection(connectionString);
    string query = "delete from stocktable1 where id=" + id;
    SqlCommand command = new SqlCommand(query, connection);
    connection.Open();
    int rowaffected = command.ExecuteNonQuery();
    connection.Close();
    stockdataGridView1.Update();
    stockdataGridView1.Refresh();  

    MessageBox.Show("deleted");
}
</code></pre>

<p>}
    }</p>

<p><a href="https://i.stack.imgur.com/FuDH1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FuDH1.jpg" alt="enter image description here"></a></p>