BramVD
BramVD

Reputation: 121

Close form override

I’ve created a winform application with lots of forms, (in mdi and dialog) but every time a close a form it stays in the memory, so I would like to use de .Dispose() option.

but I don’t want to add this code to ALL of the forms, I just want to place one code that’s activates on a FormClose command, can i use en override.onFormClose command?

and where in the application do I put this code, I tried it at the MDI form, but without success

Thanks, Bram

ps i'm using DevExpress components

Upvotes: 1

Views: 232

Answers (2)

Vytalyi
Vytalyi

Reputation: 1695

Craete a separate base class, implement your dispose method, and then inherit all forms from this class

Upvotes: 0

Justin Harvey
Justin Harvey

Reputation: 14672

If you call GC.Collect() and the forms are still in memory, then it is because there is a reference held to them somewhere.

You need to trace all references and make sure they are being released.

Upvotes: 2

Related Questions