How do I add Dispose functionality to a C# UserControl?

All Component classes implement a Disposed event. You can add an event handler for that event and clean up things in there.

For example, in your UserControl you could add following method:

private void OnDispose(object sender, EventArgs e)
{
    // do stuff on dispose
}

And in constructor (or in Load event handler) add the following line:

Disposed += OnDispose;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)