Second Version
I’m populating a ListBox using the following code
private BindingSource sri = new BindingSource();
public void sola()
{
sri.DataSource = llenar.Tables["tipoender"];
listBox1.DataSource = sri;
listBox1.ValueMember = "end_tipoendereco";
listBox1.DisplayMember = "tpl_descricao";
}
I use this to DELETE (updating with the value 2 a determined column), when the column ID_tipoauditoria value =2 the record is not loaded . This code is working
DataSet grava = new DataSet();
SqlDataAdapter da4 = new SqlDataAdapter();
SqlCommandBuilder constru8 = new SqlCommandBuilder(da4);
SqlParameter codi = new SqlParameter("@emp", SqlDbType.Int);
codi.Value = codem;
SqlCommand llena10 = new SqlCommand("dmlpjende", conec1);
llena10.Parameters.Add(codi);
llena10.CommandType = CommandType.StoredProcedure;
da4.SelectCommand = llena10;
da4.Fill(grava, "endere");
DataRow dr2 = grava.Tables["endere"].Rows[ni];
// listBox1.BackColor = Color.Red;
dr2.BeginEdit();
dr2["id_tipoauditoria"] = 2;
dr2.EndEdit();
da4.Update(grava.Tables["endere"]);
What is the best method to refresh the ListBox? I have tried resetting the binding with no-success. I only need to refresh the dataset or the listbox.
i have solve the problem of refresh the listbox, loading again the dataset,
I like use dispose and refresh but this way work.