Child window closes after button click event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreemathy2000
    New Member
    • Oct 2007
    • 40

    Child window closes after button click event

    I have a vague problem..

    Inmy windows application in c#, i'm opening a child window from from my main window thru the show method.

    I have few events on the child window. After my button click event on the child window, it closes and control comes back to the main window.

    not sure why the child window is closing.
    please let me know if anybody has faced this problem.
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Can you print your button click event code please. Are you certain you're not calling a me.close or form.close method anywhere?

    Dr B

    Comment

    • sreemathy2000
      New Member
      • Oct 2007
      • 40

      #3
      Yeah...I'm not calling any of the close methods. This is a MVC pattern and i have the click event code in the controller. in the event call, I'm just clearing the text boxes. The view closes after the click event.

      Code:
            
              private void btn_Clear_Click(object sender, EventArgs e)
              {
                  _view.m_textBoxEmailSubject.Clear();
                  _view.m_textBoxEmailTo.Clear();
                  _view.cboSchdule.SelectedIndex = 0;
                 
              }

      Comment

      • sreemathy2000
        New Member
        • Oct 2007
        • 40

        #4
        I found out the problem. The Dialog result for the buttons were set to "No" by the windows generated code. thats is the reason why the form was closing on click of the button. Once i removed that line from the designer file everything worked.

        Hope it helps some one..

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          The Form itself will have a properties on the Properties page where you can remove the dialog result buttons

          Comment

          Working...