Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Mdi problemo

Mdi problemo

Scheduled Pinned Locked Moved C#
helpcsharpsales
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    datainjector
    wrote on last edited by
    #1

    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

    H 2 Replies Last reply
    0
    • D datainjector

      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

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      If 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, call cust.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 as Form.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-----

      1 Reply Last reply
      0
      • D datainjector

        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

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        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 the ShowDialog 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 the Form.AcceptButton and Form.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-----

        D 1 Reply Last reply
        0
        • H Heath Stewart

          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 the ShowDialog 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 the Form.AcceptButton and Form.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-----

          D Offline
          D Offline
          datainjector
          wrote on last edited by
          #4

          Thanks alot for the help :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups