Dear All,
I need your help to solve below issue:-
I have an issue when I am trying to close a windows form by calling form.close() function.
The scenario is mentioned below:-
I am using a mdi form. From menu I opened a child form. Then from child form(child), I opened another form(non -child)outside the container. in non child form I am using a database insert function. After insert, I am closing the non child form and I need to re open the child form in order to reflect the data saved from non child form.
in non child form , I wrote like this:-
frmMain mainObj = new frmMain();
Close();
mainObj.OpenAssetViewForm();
And in Main form , i wrote like this to open child form within container.
- public void OpenAssetViewForm()
- {
- try
- {
- foreach (Form frmObj in Application.OpenForms)
- {
- if (frmObj.Name == "frmAssetRegView")
- {
- frmObj.Close();
- if (frmObj == null)
- {
- frmObj.Show();
- }
- break;
- }
- }
- }
- catch (Exception ex)
- {
- }
- }