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. Again dialog ... :(

Again dialog ... :(

Scheduled Pinned Locked Moved C#
questionhelp
6 Posts 3 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.
  • K Offline
    K Offline
    Karavaev Denis
    wrote on last edited by
    #1

    Ok, thanks everyone, but I have one more question. To gett callback of my modal dialog I use this code: ModalDlgClass myDlg = new ModalDlgClass(); if(myDlg.ShowDialog() == DialogResult.OK) { //Do smf. } But in the modal dialog there is a small problem ... I need to check something before close it. if(textBox1.Text.Length == 0) { //cheking and need returf focus to modal dialog } else { //do smf else, then this.Close(); // I need 2 close it ONLY if textBox1 is not emty } But if my textBox1 is empty after checking modal dialog is closing ... is there any way not to close it? thanks ===================== http://wasp.elcat.kg

    M M 2 Replies Last reply
    0
    • K Karavaev Denis

      Ok, thanks everyone, but I have one more question. To gett callback of my modal dialog I use this code: ModalDlgClass myDlg = new ModalDlgClass(); if(myDlg.ShowDialog() == DialogResult.OK) { //Do smf. } But in the modal dialog there is a small problem ... I need to check something before close it. if(textBox1.Text.Length == 0) { //cheking and need returf focus to modal dialog } else { //do smf else, then this.Close(); // I need 2 close it ONLY if textBox1 is not emty } But if my textBox1 is empty after checking modal dialog is closing ... is there any way not to close it? thanks ===================== http://wasp.elcat.kg

      M Offline
      M Offline
      Masaaki Onishi
      wrote on last edited by
      #2

      Hello, the codegurus around the world.;) If you work for MFC, you will figure it out. Maybe, you just declare MyDialog_OnClose message method, and filter the textbox input. And, if there is no input, just return before the base class Close is called. Just put "return". I believe that this works. Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)

      -Masaaki Onishi-

      K 1 Reply Last reply
      0
      • M Masaaki Onishi

        Hello, the codegurus around the world.;) If you work for MFC, you will figure it out. Maybe, you just declare MyDialog_OnClose message method, and filter the textbox input. And, if there is no input, just return before the base class Close is called. Just put "return". I believe that this works. Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)

        -Masaaki Onishi-

        K Offline
        K Offline
        Karavaev Denis
        wrote on last edited by
        #3

        I deed, but it, not working. I have modal dialog. And it's closing even if i put 'return'. Maybe it is becourse I click on button with 'OK' dialog properties? But is it only way to get response from my Modal dialog? ===================== http://wasp.elcat.kg

        M 1 Reply Last reply
        0
        • K Karavaev Denis

          I deed, but it, not working. I have modal dialog. And it's closing even if i put 'return'. Maybe it is becourse I click on button with 'OK' dialog properties? But is it only way to get response from my Modal dialog? ===================== http://wasp.elcat.kg

          M Offline
          M Offline
          Masaaki Onishi
          wrote on last edited by
          #4

          Hello, the codegurus around the world.;) Oooops, you're right because I got the same result. So, I asked "HELP" of VC#. 1) Use DialogResult.NONE

          protected void btnOK_Click (object sender, System.EventArgs e)
          {
          // OK button clicked.
          // get new message.
          strMessage = txtMessage.Text;

          if(strMessage == "") 
          {
          	MessageBox.Show(this, "Error");
          	DialogResult = DialogResult.None;
          }
          

          }

          1. Disable OK button if TextBox is empty

          private void Msg_TextChanged(object sender, System.EventArgs e)
          {
          if(txtMessage.Text == "")
          btnOK.Enabled = false;
          else
          btnOK.Enabled = true;
          }

          Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)

          -Masaaki Onishi-

          K 1 Reply Last reply
          0
          • M Masaaki Onishi

            Hello, the codegurus around the world.;) Oooops, you're right because I got the same result. So, I asked "HELP" of VC#. 1) Use DialogResult.NONE

            protected void btnOK_Click (object sender, System.EventArgs e)
            {
            // OK button clicked.
            // get new message.
            strMessage = txtMessage.Text;

            if(strMessage == "") 
            {
            	MessageBox.Show(this, "Error");
            	DialogResult = DialogResult.None;
            }
            

            }

            1. Disable OK button if TextBox is empty

            private void Msg_TextChanged(object sender, System.EventArgs e)
            {
            if(txtMessage.Text == "")
            btnOK.Enabled = false;
            else
            btnOK.Enabled = true;
            }

            Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)

            -Masaaki Onishi-

            K Offline
            K Offline
            Karavaev Denis
            wrote on last edited by
            #5

            Yah!!! thanks, Nice idea to lock button till text is empty! ;) ===================== http://wasp.elcat.kg

            1 Reply Last reply
            0
            • K Karavaev Denis

              Ok, thanks everyone, but I have one more question. To gett callback of my modal dialog I use this code: ModalDlgClass myDlg = new ModalDlgClass(); if(myDlg.ShowDialog() == DialogResult.OK) { //Do smf. } But in the modal dialog there is a small problem ... I need to check something before close it. if(textBox1.Text.Length == 0) { //cheking and need returf focus to modal dialog } else { //do smf else, then this.Close(); // I need 2 close it ONLY if textBox1 is not emty } But if my textBox1 is empty after checking modal dialog is closing ... is there any way not to close it? thanks ===================== http://wasp.elcat.kg

              M Offline
              M Offline
              mikasa
              wrote on last edited by
              #6

              I had to do this in VB.NET. What I did was I didn't "HardCode" the "Dialog Result Codes" into my Command Buttons. When the User clicked the "Login" Button of my Form, I would Validate the Login info, if it was Correct, I would just Type "Return DialogResult.OK", otherwise I would not return anything.

              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