Leon Barkan Leon Barkan - 2 months ago 5x
C# Question

Refresh list on Events

In my application i have listbox that updated from database.

The changes that can be [Buttons] (OnClick events)

  • Insert new row/rows.

  • Delete row/rows.

  • Edit Row.

  • Refresh the list.

i have a function to do the refresh:

public void DBListBoxRefresh()
dbListBox.DataSource = dbPersonList;

How can i made Event That on every event of that type will refresh the listbox automatically. or other ideas how can i make it instead of invoking the function from every event


You can simply go with += for specific event.

For example:

btnMyButton.Click += CustomEventForMyButton;

private void CustomEventForMyButton(object sender, EventArgs e)
        throw new NotImplementedException();