Code Sends Me To A New Page Before Completion
-
Hello, I have written a 2 page program. The first page connects to a remote database so that queries can be run from the second page. Once the connection is established, that second page is navigated to using a button that calls the ShowDialog command. On the second page, I construct a query from an assortment of listview boxes and send the results to a DataGridView. So far so good....everything works to this point. Now, I have a rich text box that shows the final SQL statement that was used to create the GridView. I want to be able to modify the command manually and run it again to get new results without leaving this page...seems simple enough...however, when I try to run the command the second time using a different run button, the first page reappears when the code is completed. I stepped through it and found that the program is sending me back to the first page and stopping in the button code that called the ShowDialog command; and then I am stuck there. I do not know why I am being forced to leave the second page and why the code doesn't simply run and put the new information into the DataGrid. Please tell me where I am going wrong.....Thank you in advance....Pat
-
Hello, I have written a 2 page program. The first page connects to a remote database so that queries can be run from the second page. Once the connection is established, that second page is navigated to using a button that calls the ShowDialog command. On the second page, I construct a query from an assortment of listview boxes and send the results to a DataGridView. So far so good....everything works to this point. Now, I have a rich text box that shows the final SQL statement that was used to create the GridView. I want to be able to modify the command manually and run it again to get new results without leaving this page...seems simple enough...however, when I try to run the command the second time using a different run button, the first page reappears when the code is completed. I stepped through it and found that the program is sending me back to the first page and stopping in the button code that called the ShowDialog command; and then I am stuck there. I do not know why I am being forced to leave the second page and why the code doesn't simply run and put the new information into the DataGrid. Please tell me where I am going wrong.....Thank you in advance....Pat
-
Hello, I have written a 2 page program. The first page connects to a remote database so that queries can be run from the second page. Once the connection is established, that second page is navigated to using a button that calls the ShowDialog command. On the second page, I construct a query from an assortment of listview boxes and send the results to a DataGridView. So far so good....everything works to this point. Now, I have a rich text box that shows the final SQL statement that was used to create the GridView. I want to be able to modify the command manually and run it again to get new results without leaving this page...seems simple enough...however, when I try to run the command the second time using a different run button, the first page reappears when the code is completed. I stepped through it and found that the program is sending me back to the first page and stopping in the button code that called the ShowDialog command; and then I am stuck there. I do not know why I am being forced to leave the second page and why the code doesn't simply run and put the new information into the DataGrid. Please tell me where I am going wrong.....Thank you in advance....Pat
-
Well, at a rough guess I would say there is either a code bug or a logic error in your program. However, without seeing some of your code it's difficult to be more precise.
The best things in life are not things.
Richard, Thank you for your reply....Yes, I agree with your input. There was so much code on this that I did not think it was OK to show it all, so I did not. I think that Bob (below) has an idea regarding the modality so I will pursue that line right now. In the meantime, I created a work around (which did not fix the issue but allowed me to get the desired result a different way). I wanted to reply though and thank you for taking the time to assist. I know you time is valuable and I appreciate it. Best Regards, Pat
-
ShowDialog returns when the form it calls is closed. So either the event handler on the second button is closing the modal form (directly or indirectly), or you have set a DialogResult on that button (which causes it to close the form).
Bob, Thank you for your reply. I will further examine the code as per your suggestion and post the solution if I am able to correct it. In the meantime, I have created a work around to solve the immediate problem, but I will not be happy until I understand the "why" of it so I can do it correctly next time. Best Regards, Pat
-
Richard, Thank you for your reply....Yes, I agree with your input. There was so much code on this that I did not think it was OK to show it all, so I did not. I think that Bob (below) has an idea regarding the modality so I will pursue that line right now. In the meantime, I created a work around (which did not fix the issue but allowed me to get the desired result a different way). I wanted to reply though and thank you for taking the time to assist. I know you time is valuable and I appreciate it. Best Regards, Pat