How can I open the same reports on the same form? [duplicate]

0

I have my next form: that is called frmNot

After clicking on the magnifying glass button, it sends me to another form that is a data catalog (frmCat) which, when clicking on any of them, generates the report. The question is that I open a form, which I do not want, I want to click on the row to open the report on the same form frmNot, but I do not want to be another. I have my next code inside the frmCat form.

 private void btnSeleccionar_Click(object sender, EventArgs e)
    {


        frmNot log = new frmNot();
        log.NumRef = dgvResultados.CurrentRow.Cells[1].Value.ToString();
        String NO_REFEREN = dgvResultados.CurrentRow.Cells[1].Value.ToString();

        log.Show();

       log.txt1.Text = NO_REFEREN;

    }

and similarly try the following code option:

  private void dgvResultados_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e)
    {

              frmNot log = Owner as frmNot;
              log.NumRef = dgvResultados.CurrentRow.Cells[1].Value.ToString();

             String NumRef = dgvResultados.CurrentRow.Cells[1].Value.ToString();


              String NO_REFEREN = dgvResultados.CurrentRow.Cells[1].Value.ToString();

              log.Show();

             log.txt1.Text = NO_REFEREN;

             log.reportViewer1.Text = NumRef;




    }

and in my frmNot I have my following code:

 private void buscarfol_Click(object sender, EventArgs e)
    {

        frmCat log = new frmCat();
        AddOwnedForm(log);
        log.ShowDialog();


    }

I hope you can help me thanks.

    
asked by SoyKrut 29.12.2017 в 21:10
source

2 answers

0

I just had to invoke my method, use the Owner and the ace

    private void btnSeleccionar_Click(object sender, EventArgs e)
{


    frmNot log = Owner as frmNot();
    log.NumRef = dgvResultados.CurrentRow.Cells[1].Value.ToString();
    String NO_REFEREN = dgvResultados.CurrentRow.Cells[1].Value.ToString();
    log.cargarReporte();


    log.Show();


   log.txt1.Text = NO_REFEREN;

}
    
answered by 03.01.2018 / 20:33
source
1

What you could do is place the code that loads the report as a procedure in the code of the frmNot form. In this way:

public void cargarReporte(String valor){

          NumRef = valor;


          String NO_REFEREN = valor;

         .txt1.Text = NO_REFEREN;

         reportViewer1.Text = NumRef

}

Then, you call the procedure on the frmCat form.

 private void dgvResultados_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e)
{
frmNot.cargarReporte(dgvResultados.CurrentRow.Cells[1].Value.ToString());
}
    
answered by 31.12.2017 в 18:49