Let me start by saying I am not an experienced developer and by no means a C# expert.
I have created a winform application though that I am having a problem with. It is a case management program that the user uses to search for cases. When selecting a case it opens in the current panel. The user can modify the case and save it. I was not disposing of any of the controls and the user objects would increase to about 1,100 when it eventually failed with the "Error Creating Window Handle". I have since disposed of the current panel on the button click event and have cut down considerably on the number of user objects but I am still getting the error after 10 searches and subsequent saves of the searched for case.
I am calling the following method to open the form to modify the case and to return to the search page when saved.
I have created a winform application though that I am having a problem with. It is a case management program that the user uses to search for cases. When selecting a case it opens in the current panel. The user can modify the case and save it. I was not disposing of any of the controls and the user objects would increase to about 1,100 when it eventually failed with the "Error Creating Window Handle". I have since disposed of the current panel on the button click event and have cut down considerably on the number of user objects but I am still getting the error after 10 searches and subsequent saves of the searched for case.
I am calling the following method to open the form to modify the case and to return to the search page when saved.
C#:
public void nav(Form form, Panel panel)
{
form.TopLevel = false;
form.Size = panel.Size;
panel.Controls.Clear();
panel.Controls.Add(form);
form.Show();
}