locked
Second Form RRS feed

  • Question

  •  Hi,

    So I created a windows application that collects various pieces of information. The user is required to enter all of the information requested on the form before submitting it. The form itself works fine, as does the pop up that informs the user he/she missed entering some information.

    The problem that I'm running into occurs after the pop up comes up. The user clicks "ok" to make the pop up go away, and is returned to the original form. However, when the user clicks "submit" again, after correcting the error, nothing happens. How do I return to the top of the method without losing any information in the form.

    This is the code I have so far:
    private void submit_button_Click(object sender, EventArgs e)  
            {  
                //checks to make sure radio button fields  
                //and check mark fields have a value  
     
                //second form declaration  
                info_warning warned = new info_warning();  
     
                variable_1 = variable_2 = variable_3 = false
                this.get_text();  
                this.get_check_values();  
     
                if (variable_1 != null)  
                    var_1_selected = true;  
                if (variable_2 != null)  
                    var_2_selected = true;  
                if (variable_3 != null)  
                    var_3_selected = true;  
     
                //creates pop up notification if any   
                //radio button fields are missing  
                if (!var_1_selected || !var_2_selected || !var_3_selected)  
                    warned.ShowDialog();  
                }  
                //********if user is missing something, i want to stop here and start over*****  
     
                //passes variables to another class  
                this.pass_variables();  
     
                //closes form  
                Close();  
            } 

    I had a do while loop surrounding everything except the last two statements, but that just made the second window pop up non-stop so that the user had no chance to change anything.

    I hope I explained my issue well enough.

    Thanks for any help.
    Thursday, June 19, 2008 8:53 PM

Answers

  • You need to break out of the procedure without calling Close() in the event that there were problems with the data.

    For example,

                if (!var_1_selected || !var_2_selected || !var_3_selected)  
                {  
                    warned.ShowDialog();  
                    return;  
                } 
    • Marked as answer by daSwede77 Monday, June 23, 2008 1:25 PM
    • Marked as answer by daSwede77 Monday, June 23, 2008 1:25 PM
    Thursday, June 19, 2008 11:57 PM
  •  For questions and discussions regarding client application development using Windows Forms controls and features, please see http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=8&SiteID=1

    http://www.peterRitchie.com/blog
    • Marked as answer by Peter Ritchie Friday, June 20, 2008 2:17 PM
    Friday, June 20, 2008 2:17 PM

All replies

  • You need to break out of the procedure without calling Close() in the event that there were problems with the data.

    For example,

                if (!var_1_selected || !var_2_selected || !var_3_selected)  
                {  
                    warned.ShowDialog();  
                    return;  
                } 
    • Marked as answer by daSwede77 Monday, June 23, 2008 1:25 PM
    • Marked as answer by daSwede77 Monday, June 23, 2008 1:25 PM
    Thursday, June 19, 2008 11:57 PM
  •  For questions and discussions regarding client application development using Windows Forms controls and features, please see http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=8&SiteID=1

    http://www.peterRitchie.com/blog
    • Marked as answer by Peter Ritchie Friday, June 20, 2008 2:17 PM
    Friday, June 20, 2008 2:17 PM