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. Checking required fields in a second Windows Form

Checking required fields in a second Windows Form

Scheduled Pinned Locked Moved C#
csharphelpquestion
38 Posts 5 Posters 9 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.
  • N Not Active

    As you are having difficulties understanding, I'll try to make this very clear, again. You stated it was easier to create the form in code. My question, once again, is to have you explain why you think this is easier?

    _Madmatt wrote:

    Are you going to tell me you don't know how to make a control in the codebehind?

    Take a better look around before making statements like this.


    only two letters away from being an asset

    _ Offline
    _ Offline
    _Madmatt
    wrote on last edited by
    #18

    Mark Nischalke wrote:

    As you are having difficulties understanding, I'll try to make this very clear, again.

    I'm so sorry, my English isn't that good. If Form1 creates Form2, Form2 can check its own textboxes. When those boxes are empty, you just display a message. If the textboxes are valid, Form2 closes itself and Form1 can still acces the textbox.Text properties. You may not Dispose Form2 for that ;) I'm not yet studying c# so you may conclude I'm beginner :)

    J N 2 Replies Last reply
    0
    • N Not Active

      I'm still waiting for your explanation.


      only two letters away from being an asset

      _ Offline
      _ Offline
      _Madmatt
      wrote on last edited by
      #19

      I'm not online all day long ;)

      L 1 Reply Last reply
      0
      • _ _Madmatt

        Mark Nischalke wrote:

        As you are having difficulties understanding, I'll try to make this very clear, again.

        I'm so sorry, my English isn't that good. If Form1 creates Form2, Form2 can check its own textboxes. When those boxes are empty, you just display a message. If the textboxes are valid, Form2 closes itself and Form1 can still acces the textbox.Text properties. You may not Dispose Form2 for that ;) I'm not yet studying c# so you may conclude I'm beginner :)

        J Offline
        J Offline
        JTRizos
        wrote on last edited by
        #20

        Thanx _Madmatt, your English is good, no problem. I understand what you are saying but am confused on the HOW. I am also new to C# and am getting used to the gotchas. I am sure the problem is with how the Dialogresult is handled, just not clear on how I need to handle it. Thanx again for your suggestions.

        _ 1 Reply Last reply
        0
        • J JTRizos

          Thanx _Madmatt, your English is good, no problem. I understand what you are saying but am confused on the HOW. I am also new to C# and am getting used to the gotchas. I am sure the problem is with how the Dialogresult is handled, just not clear on how I need to handle it. Thanx again for your suggestions.

          _ Offline
          _ Offline
          _Madmatt
          wrote on last edited by
          #21

          You're welcome! Maybe you can show your Form2 just in a form and not in a Dialog. Then you just check if your textboxes are empty like this: if (txt1.Text == null) { // TextBox1 is empty } else if(txt1.Text != null) { // TextBox is not empty do something with the text ;) }

          1 Reply Last reply
          0
          • J JTRizos

            Thank you ... that handled Form2 popping up twice and I learned something. I thought the first one opened the form and the second was just a check. However, the check for an empty textbox now just drops through even if a textbox is empty and the message appears. Am I missing something on how Form2 is processed versus how Form1 is processed? Maybe which form is the primary form? I would expect for the process to stay within the if/else until the textboxes are no longer empty. That is what similar code in Form1 does. Almost there. Thanx again

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #22

            I would suggest you maybe email me what you have. That way I can take a look at the whole problem and maybe be better able to help you at this point.


            only two letters away from being an asset

            J 1 Reply Last reply
            0
            • _ _Madmatt

              Mark Nischalke wrote:

              As you are having difficulties understanding, I'll try to make this very clear, again.

              I'm so sorry, my English isn't that good. If Form1 creates Form2, Form2 can check its own textboxes. When those boxes are empty, you just display a message. If the textboxes are valid, Form2 closes itself and Form1 can still acces the textbox.Text properties. You may not Dispose Form2 for that ;) I'm not yet studying c# so you may conclude I'm beginner :)

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #23

              _Madmatt wrote:

              I'm so sorry, my English isn't that good.

              I don't buy this excuse You still have not answered the question, why is doing it in code better? But no matter, not worth continuing based on below.

              _Madmatt wrote:

              I'm not yet studying c#

              Then you absolutely should not have answered in the first place :mad::mad:


              only two letters away from being an asset

              _ 1 Reply Last reply
              0
              • N Not Active

                _Madmatt wrote:

                I'm so sorry, my English isn't that good.

                I don't buy this excuse You still have not answered the question, why is doing it in code better? But no matter, not worth continuing based on below.

                _Madmatt wrote:

                I'm not yet studying c#

                Then you absolutely should not have answered in the first place :mad::mad:


                only two letters away from being an asset

                _ Offline
                _ Offline
                _Madmatt
                wrote on last edited by
                #24

                Mark Nischalke wrote:

                Then you absolutely should not have answered in the first place

                You don't give beginners a chance? Ow that's pretty nice...

                N 1 Reply Last reply
                0
                • _ _Madmatt

                  Mark Nischalke wrote:

                  Then you absolutely should not have answered in the first place

                  You don't give beginners a chance? Ow that's pretty nice...

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #25

                  Beginners, yes. However, by your own admission you do not even know the language. You can't comment on things you don't know!!:mad:


                  only two letters away from being an asset

                  _ 1 Reply Last reply
                  0
                  • N Not Active

                    Beginners, yes. However, by your own admission you do not even know the language. You can't comment on things you don't know!!:mad:


                    only two letters away from being an asset

                    _ Offline
                    _ Offline
                    _Madmatt
                    wrote on last edited by
                    #26

                    Mark Nischalke wrote:

                    you do not even know the language.

                    I know the language. I've read a book. But I'm still at secundary school, so I've not studied c# yet at high school. I surely know the language, otherwise it would be stupid to wate my time on it...

                    N 1 Reply Last reply
                    0
                    • J JTRizos

                      No, I don't but it seems I need to look closer at the code. The required field code you suggested in Form2 is processed twice (that's for submittals with an empty field) and then drops back to the next step in the code back in Form1 even if both fields are not filled. Cannot figure out why but it seems to want to process Form2 just twice or pop up Form2 again if the fields are filled. Thanx for your help. If you can think of something or anyone else who offered an answer earlier, I would be much appreciative. :~

                      C Offline
                      C Offline
                      CodyDaemon
                      wrote on last edited by
                      #27

                      JTRizos: "No, I don't" Err... yes you do!

                      Form2 qForm = new Form2();
                      qForm.ShowDialog();

                      if (qForm.ShowDialog ()== DialogResult.OK)

                      J 1 Reply Last reply
                      0
                      • C CodyDaemon

                        JTRizos: "No, I don't" Err... yes you do!

                        Form2 qForm = new Form2();
                        qForm.ShowDialog();

                        if (qForm.ShowDialog ()== DialogResult.OK)

                        J Offline
                        J Offline
                        JTRizos
                        wrote on last edited by
                        #28

                        Yes, I know. Learned that yesterday. Still learning C# and it's little proclivities. Thanx for responding.

                        1 Reply Last reply
                        0
                        • _ _Madmatt

                          I'm not online all day long ;)

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #29

                          Surely you could have just answered his question instead of writing "I'm not online all day long"? I wouldn't argue further, your logic isn't correct, and you might want to reread those books of yours.

                          Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

                          _ 1 Reply Last reply
                          0
                          • L Lost User

                            Surely you could have just answered his question instead of writing "I'm not online all day long"? I wouldn't argue further, your logic isn't correct, and you might want to reread those books of yours.

                            Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

                            _ Offline
                            _ Offline
                            _Madmatt
                            wrote on last edited by
                            #30

                            I don't know if you can read, but I've already answered... Read the whole topic before you say stupid things like that. EDIT: What I said was just a suggestion about how he COULD do it. I've ABSOLUTELY NOT said "this is the best solution". It's the solution how I should do it with my skills and my understoodings about his issues. But if there are better solutions, no problem for me! I have still to learn, but it's not needed to slap me down. Everybody here has ever started with something where there were better solutions for? Or was you a pro from the first day on? Last but not least a quote from the rules: "Let's work to help developers, not make them feel stupid.."

                            modified on Thursday, October 29, 2009 1:15 PM

                            L 1 Reply Last reply
                            0
                            • _ _Madmatt

                              I don't know if you can read, but I've already answered... Read the whole topic before you say stupid things like that. EDIT: What I said was just a suggestion about how he COULD do it. I've ABSOLUTELY NOT said "this is the best solution". It's the solution how I should do it with my skills and my understoodings about his issues. But if there are better solutions, no problem for me! I have still to learn, but it's not needed to slap me down. Everybody here has ever started with something where there were better solutions for? Or was you a pro from the first day on? Last but not least a quote from the rules: "Let's work to help developers, not make them feel stupid.."

                              modified on Thursday, October 29, 2009 1:15 PM

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #31

                              Funny, I don't see that in the rules[^]. Plus, I'm not the one who looks stupid here. And you did say it was the easiest method, and you where asked how and ignored it. If anything, you proved your own stupidity, not mine.

                              Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

                              _ 1 Reply Last reply
                              0
                              • L Lost User

                                Funny, I don't see that in the rules[^]. Plus, I'm not the one who looks stupid here. And you did say it was the easiest method, and you where asked how and ignored it. If anything, you proved your own stupidity, not mine.

                                Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

                                _ Offline
                                _ Offline
                                _Madmatt
                                wrote on last edited by
                                #32

                                Are you blind??? Apologies for the shouting but this is important. When answering a question please: 1.Read the question carefully 2.Understand that English isn't everyone's first language so be lenient of bad spelling and grammar 3.If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome 4.If the question is inappropriate then click the 'vote to remove message' button Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..

                                L 1 Reply Last reply
                                0
                                • _ _Madmatt

                                  Are you blind??? Apologies for the shouting but this is important. When answering a question please: 1.Read the question carefully 2.Understand that English isn't everyone's first language so be lenient of bad spelling and grammar 3.If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome 4.If the question is inappropriate then click the 'vote to remove message' button Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #33

                                  Again, you never asked the question, so that really doesn't apply to you. If someone asks a question, and another gives an answer that is wrong, or clearly not what is desired, then a 'slap-down' is necessary. You didn't ask for the help, so there is no help for you given. I'm not making you feel stupid either, I think you are accomplishing that on your own.

                                  Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

                                  _ 1 Reply Last reply
                                  0
                                  • L Lost User

                                    Again, you never asked the question, so that really doesn't apply to you. If someone asks a question, and another gives an answer that is wrong, or clearly not what is desired, then a 'slap-down' is necessary. You didn't ask for the help, so there is no help for you given. I'm not making you feel stupid either, I think you are accomplishing that on your own.

                                    Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

                                    _ Offline
                                    _ Offline
                                    _Madmatt
                                    wrote on last edited by
                                    #34

                                    Again, I've replied, but my answer was wrong. Okay, I really accept it... I've answered wrong. I've answered wrong. I've answered wrong. I've answered wrong. I've answered wrong. I'm soooooooo sorry. Man, everyone has to learn... Okay, I said it was the easiest method to do it, but that was following my skills. I've already said I accept another solution. But no, again someone has to start a discussion...

                                    1 Reply Last reply
                                    0
                                    • N Not Active

                                      I would suggest you maybe email me what you have. That way I can take a look at the whole problem and maybe be better able to help you at this point.


                                      only two letters away from being an asset

                                      J Offline
                                      J Offline
                                      JTRizos
                                      wrote on last edited by
                                      #35

                                      GOT IT!!!!! Thank you all for your input. The trick is to set the DialogResult to None in properties. :-D :-D :-D Also, I sure hope you all work out this smal argument. :sigh: :sigh:

                                      N 1 Reply Last reply
                                      0
                                      • J JTRizos

                                        GOT IT!!!!! Thank you all for your input. The trick is to set the DialogResult to None in properties. :-D :-D :-D Also, I sure hope you all work out this smal argument. :sigh: :sigh:

                                        N Offline
                                        N Offline
                                        Not Active
                                        wrote on last edited by
                                        #36

                                        Excellent.


                                        I know the language. I've read a book. - _Madmatt

                                        1 Reply Last reply
                                        0
                                        • _ _Madmatt

                                          Mark Nischalke wrote:

                                          you do not even know the language.

                                          I know the language. I've read a book. But I'm still at secundary school, so I've not studied c# yet at high school. I surely know the language, otherwise it would be stupid to wate my time on it...

                                          N Offline
                                          N Offline
                                          Not Active
                                          wrote on last edited by
                                          #37

                                          http://www.codeproject.com/Messages/3252116/Re-Checking-required-fields-in-a-second-Windows-Fo.aspx[^]

                                          _Madmatt wrote:

                                          I'm not yet studying c#

                                          _Madmatt wrote:

                                          I surely know the language,

                                          So which is it? Do you know the language or not? Are you confused or just a liar? But hey, thanks for giving me a new sig :laugh:


                                          I know the language. I've read a book. - _Madmatt

                                          _ 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