Mdi problemo
-
Okay here is what the problemo is .. I am using MDI ... so i have this modal dialog box which opens up when the user clicks on a menuitem ... The person needs to enter some info into the dialog and click okay after that the values are passed to another form that is a MDI Child to the main form ... The problem is when the user clicks the close button the programm crashes ... I know why it does that because on the Okay button i inserted the code in the closing event so when the person closes the modal dialog with out filling anyhting in it .. it crashes which makes sence ... I cant find a way to get around this problem ... The programm is a video lib managment system ... the modal dialog takes in the users code and opens the renting form ... Which is the mdi child .. let me post the code it might help
CustomerCodeDialog cust == new CustomerCodeDialog(); cd.ShowDialog(); string customer_code = cust.getCustomerCode(); //which is a function that retrives the customer code from the text box string custoerm_name = cust.getCustomerName(); issueWindow issue = new isuueWindow(); issueWindow.MdiParent = this; issueWindow.Show();
And please i cant find a good tutorials on MDI form for C# on codeProject or any other web site .. any links would help me alot... Sorry my wnglish isnt that great ... Thanks DaIn -
Okay here is what the problemo is .. I am using MDI ... so i have this modal dialog box which opens up when the user clicks on a menuitem ... The person needs to enter some info into the dialog and click okay after that the values are passed to another form that is a MDI Child to the main form ... The problem is when the user clicks the close button the programm crashes ... I know why it does that because on the Okay button i inserted the code in the closing event so when the person closes the modal dialog with out filling anyhting in it .. it crashes which makes sence ... I cant find a way to get around this problem ... The programm is a video lib managment system ... the modal dialog takes in the users code and opens the renting form ... Which is the mdi child .. let me post the code it might help
CustomerCodeDialog cust == new CustomerCodeDialog(); cd.ShowDialog(); string customer_code = cust.getCustomerCode(); //which is a function that retrives the customer code from the text box string custoerm_name = cust.getCustomerName(); issueWindow issue = new isuueWindow(); issueWindow.MdiParent = this; issueWindow.Show();
And please i cant find a good tutorials on MDI form for C# on codeProject or any other web site .. any links would help me alot... Sorry my wnglish isnt that great ... Thanks DaInIf the inputs are validating, crashing the problem makes sense?! :wtf: You need to validate your inputs and gracefully warn the user or exit, depending on the circumstances (exiting, like in the case of 3 invalid password attempts or something). Crashing your program is not acceptable for clients! Besides, never trust user input. Always validate input, even if it's just checking to see if input was provided. You should also put such commands in try-catch blocks so execeptions are caught and handled correctly. One more thing, when using modal dialogs, you need to dispose them when you're done. So, after you get done grabbing values form your
cust
variable, callcust.Dispose()
. Otherwise, the memory for the modal dialog (actually, this has to do with native handles used to display the modal dialog) won't be freed. This also helps keeps the memory footprint of your app down. As far as MDI tutorials, I can't recommend any, but you should read the .NET SDK Documentation for the MDI-related methods and properties, such asForm.MdiChildren
,Form.MdiParent
,Menu.MergeMenu
, and the like. It's not great, but it might give you a little more insight to some specific questions you might have. Otherwise, just ask the forum! :)-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Okay here is what the problemo is .. I am using MDI ... so i have this modal dialog box which opens up when the user clicks on a menuitem ... The person needs to enter some info into the dialog and click okay after that the values are passed to another form that is a MDI Child to the main form ... The problem is when the user clicks the close button the programm crashes ... I know why it does that because on the Okay button i inserted the code in the closing event so when the person closes the modal dialog with out filling anyhting in it .. it crashes which makes sence ... I cant find a way to get around this problem ... The programm is a video lib managment system ... the modal dialog takes in the users code and opens the renting form ... Which is the mdi child .. let me post the code it might help
CustomerCodeDialog cust == new CustomerCodeDialog(); cd.ShowDialog(); string customer_code = cust.getCustomerCode(); //which is a function that retrives the customer code from the text box string custoerm_name = cust.getCustomerName(); issueWindow issue = new isuueWindow(); issueWindow.MdiParent = this; issueWindow.Show();
And please i cant find a good tutorials on MDI form for C# on codeProject or any other web site .. any links would help me alot... Sorry my wnglish isnt that great ... Thanks DaInOh, and as far as validating inputs, it's common practice to not let the user close the dialog until they've either canceled the dialog or enter the valid values. You should also get a
DialogResult
back from theShowDialog
call so you know what the user did:DialogResult result = cust.ShowDialog();
if (result != DialogResult.OK) return;Or something like that. Then, in your form, make sure your OK and Cancel buttons have the right
DialogResult
property set (OK or Cancel), and that your form specifies theForm.AcceptButton
andForm.CancelButton
.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Oh, and as far as validating inputs, it's common practice to not let the user close the dialog until they've either canceled the dialog or enter the valid values. You should also get a
DialogResult
back from theShowDialog
call so you know what the user did:DialogResult result = cust.ShowDialog();
if (result != DialogResult.OK) return;Or something like that. Then, in your form, make sure your OK and Cancel buttons have the right
DialogResult
property set (OK or Cancel), and that your form specifies theForm.AcceptButton
andForm.CancelButton
.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
Thanks alot for the help :)