views:

275

answers:

2

I have two forms, in the main one a have a crystalreportviewer and in the other one the user introduces the ID of the user he wants to be on the report. The problem I want the user to introduce the ID before the report loads the information, so when the user clicks the CreateReport button just before the report loads the info, I created a new form to introduce the ID, the problem is that instructions continue to execute even though the new window is open. I know is a problem of logic instead of programmin maybe you can help me =). I made a constructor in the form so the values can be passed.

Here is the code of the button:

    private void usuariosToolStripMenuItem_Click(object sender, EventArgs e)
    {

            RPE formRPE = new RPE(); //NEW FORM CREATED
            frmRPE.Show();//RPE FORM CALLED
            this.Hide();

        //BUT IT GOES ON

            ReportDocument guantesRpt = new reporteGuantes();

            DataTable datatableGuantes = reporteguantes.obtenerTabla();
            guantesRpt.SetDataSource(datatableGuantes);





            rptViewerGuantes.ReportSource = guantesRpt;
            //  Usuariorpt.SetParameterValue("RPE", RPE);



    }
+2  A: 

ShowDialog(...)

Brad Bruce
thank you! It worked perfectly
YeomansLeo
+1  A: 

Form.show() is used when you want a modeless form. So when you call show it sets up the form to run on its on and then continues to execute the code where you called the show.

Since you want to block the user input and code execution until they deal with your report ID form, you want a modal form. As such look at Form.ShowDialog() which will block execution until the form is dismissed and will then give you a DialogResult where you can retreive the result from the user and then get any form specific information from the form instance. Here is the msdn for ShowDialog()

Brandon Bodnár
thank you very much, I will read the msdn page!
YeomansLeo