Hi
I've got a listbox which has a datasource. Now, when someone press on a button 'delete'. I want that the last created object is deleted. And then you return to the panel with the listbox. You always see the object you deleted. This I want to remove.
public void btnCreate_Click(object sender, EventArgs e)
{
// more code above
ProcessList.Add(p);
lbCreatedProcesses.DataSource = null;
lbCreatedProcesses.DataSource = ProcessList;
// more code under
}
private void llProcesDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
Proces leeg = null;
int totaal = ProcessList.Count;
ProcessList[totaal - 1] = leeg;
//MessageBox.Show(leeg.PNaam + " wordt verwijderd");
pnlPMaken.Visible = true;
pnlBMaken.Visible = false;
pnlOverzicht.Visible = false;
pnlConti.Visible = false;
pnlStap.Visible = false;
// empty everything
number--;
tBArrival.Text = "";
tBName.Text = "Proces ";
cmbStatus.SelectedIndex = -1;
// this can't because ProcessList is DataSource
lbCreatedProcesses.Items.RemoveAt(totaal - 1);
//lbCreatedProcesses.DataSource = null;
lbCreatedProcesses.DataSource = ProcessList;
pnlOverzicht.Invalidate();
}
catch (ArgumentNullException ane) { ane.ToString(); }
}
Does someone knows a way to solve this?