Windows Form
-
I have come across with a little problem that must be simpler for you guys; As a matter of fact, i m new in .Net/C# environment, hence i m facing a little bit difficulty in writing code. I have a form (Non-MDI); on its next button after successfull execution of a method i have to open a new form and for doing this i have written the following code: DBSecurity.DBSecurity msecure=new DBSecurity.DBSecurity(strServer,strUser,strPwd,strDatabase); if (msecure.Generate(txtCompany.text,txtLocation.Text)==true) { SecurityGUI.frmGUI frm=new frmGUI(); frm.ShowDialog(); this.Close(); } this code works fine as far as frmGUI form opening is concerned but it do not close the existing form and it still open on back. Am i writing wrong code? or do you have another solution?
-
I have come across with a little problem that must be simpler for you guys; As a matter of fact, i m new in .Net/C# environment, hence i m facing a little bit difficulty in writing code. I have a form (Non-MDI); on its next button after successfull execution of a method i have to open a new form and for doing this i have written the following code: DBSecurity.DBSecurity msecure=new DBSecurity.DBSecurity(strServer,strUser,strPwd,strDatabase); if (msecure.Generate(txtCompany.text,txtLocation.Text)==true) { SecurityGUI.frmGUI frm=new frmGUI(); frm.ShowDialog(); this.Close(); } this code works fine as far as frmGUI form opening is concerned but it do not close the existing form and it still open on back. Am i writing wrong code? or do you have another solution?
Hi, in the .NET documentation about the Form class ShowDialog() method it says this: "You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed." That means that the behaviour you describe is wanted. It's not a bug, it's a feature ;) Try the Show() method. That could be your solution. Regards, Udo
-
I have come across with a little problem that must be simpler for you guys; As a matter of fact, i m new in .Net/C# environment, hence i m facing a little bit difficulty in writing code. I have a form (Non-MDI); on its next button after successfull execution of a method i have to open a new form and for doing this i have written the following code: DBSecurity.DBSecurity msecure=new DBSecurity.DBSecurity(strServer,strUser,strPwd,strDatabase); if (msecure.Generate(txtCompany.text,txtLocation.Text)==true) { SecurityGUI.frmGUI frm=new frmGUI(); frm.ShowDialog(); this.Close(); } this code works fine as far as frmGUI form opening is concerned but it do not close the existing form and it still open on back. Am i writing wrong code? or do you have another solution?
Try hiding your "parent" form instead and re-show it when you're done with the "child" (frmGUI) one:
SecurityGUI.frmGUI frm = new frmGUI();
this.Hide();
frm.ShowDialog();
this.Show();This will work fine since after closing the child form, the applications' control will return to the line that immediately follows the ShowDialog() method. Regards, Polis Can you practice what you teach?
-
Try hiding your "parent" form instead and re-show it when you're done with the "child" (frmGUI) one:
SecurityGUI.frmGUI frm = new frmGUI();
this.Hide();
frm.ShowDialog();
this.Show();This will work fine since after closing the child form, the applications' control will return to the line that immediately follows the ShowDialog() method. Regards, Polis Can you practice what you teach?
thanks Poils, It works fine.