Frage

hi i have a mdi application. in which i have a mdiparent which is menu form.Now i have a requisition form.Now when all the deatils hav been filled there is dialogue box which says details filled sucessfully. on the click of Ok in message box i am suppose to go back to the menu page and also close the requisition form. But th requisition form does not close. ith still remains in the background. here is the code:

private void btnsave_Click_1(object sender, EventArgs e)
{
 DialogResult dialogResult = MessageBox.Show("record saved", "requisition", MessageBoxButtons.OK, MessageBoxIcon.Information);
            if (dialogResult == DialogResult.OK)
            {

                frmmain main = new frmmain();
                main.Show();

                frmrequisition requisition = new frmrequisition();
                requisition.Close();
            }

            else
            {
                MessageBox.Show("error", "requisition", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

}
War es hilfreich?

Lösung

You are creating a new instance of the requisition form, and calling the close method on that instance:

frmrequisition requisition = new frmrequisition();
requisition.Close();

You should close the requisition that was being displayed. Have you tried this.Close(), assuming the event handler is part of the requisition form?

Andere Tipps

Your creating a new object and closing that. you need to have a reference to your frmrequisition that is currently displayed.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top