locked
Crystalreportviewer is not accessible due to its protection level

    Question

  • Hi i'm using c#.net (vs2008) and attempting to load a crystal report in a cystalreportviewer control contained in another form.

    The code for the event for the button click i'm using to load the report is:

    private void button1_Click(object sender, EventArgs e)
        {
          this.demoSalesTableAdapter.Fill(this.chartfxLiteSamplesDataSet.DemoSales);
          frmrpt myform = new frmrpt();
          CrystalReport2 rpt = new CrystalReport2();
          rpt.SetDataSource(chartfxLiteSamplesDataSet);
         
          myform.crystalReportViewer1.ReportSource = rpt;
          myform.WindowState = FormWindowState.Maximized;
          myform.Show();
        }
    

    The problem is when i run the project, there is an errror: "crystalreportviewer1 is inaccessible due to its protection level"   where i say

     myform.crystalReportViewer1.ReportSource = rpt;
    
    

    frmrpt is the form that contains the crystalreportviewer1;

    this code is contained within the button control of frmparam which are all within the project.

     

    Please help. It has bugged me for hours.

     


    Kangz
    Thursday, October 21, 2010 7:13 AM

Answers

  • Hi Kangz,

    Welcome to MSDN forums!

    You should make CrystalReportViewer as a public control in frmrpt Form.

    Try find the Modifiers property and change it to public.

     

    Hope these helps, if you have any problems, please feel free to let me know.

    Best Regards,
    Alan Chen
    ________________________________________
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    • Marked as answer by kangzy Monday, October 25, 2010 8:41 AM
    Monday, October 25, 2010 7:28 AM

All replies

  • Hi Kangz,

    Welcome to MSDN forums!

    You should make CrystalReportViewer as a public control in frmrpt Form.

    Try find the Modifiers property and change it to public.

     

    Hope these helps, if you have any problems, please feel free to let me know.

    Best Regards,
    Alan Chen
    ________________________________________
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    • Marked as answer by kangzy Monday, October 25, 2010 8:41 AM
    Monday, October 25, 2010 7:28 AM
  • Thanks Alan. It works perfect. I'm trying to convert myself from vb.net to C# so i was thinking this must be another C# specific problem since it works perfectly in vb. Again thanks.
    Kangz
    Monday, October 25, 2010 8:45 AM