I have adopted a technique in VB.NET that allows me to design a group control with several children controls as a template that can be cloned as needed. I instantiate the template form that holds the group control, then insert the group control into my application's form. This is leaking memory and I do not know how to get rid of the leak. What is the proper way to dispose of the template form and group control?
I have included a simplified sample of what the source code looks like.
Public Class MainForm
Private templateObject as object
Public Sub CreateNewGroupBoxTemplate()
Dim tempTemplateForm as new FTemplateForm
templateObject = tempTemplateForm.grpTemplateGroupControl
Public Sub DeleteTemplate()