У меня есть форма, которая содержит программу просмотра отчетов Crystal, в коде этой формы я загружаю данные в программу просмотра отчетов Crystal, таким образом получая данные из таблицы, которая работает нормально и показывает данные:
// Declare a class named Cliente
public class Cliente
{
public int iId { get; set; }
public string sNombre { get; set; }
public string sNIF { get; set; }
public string sDireccion { get; set; }
public string sTelefono { get; set; }
public string sEmail { get; set; }
public string sWeb { get; set; }
public bool bActivo { get; set; }
public string sObservacion { get; set; }
}
// I declare the variables
Cliente oCliente = new Cliente();
// Get data like select * from cliente with the function
oCliente = GetClienteData("Table_Clientes", Id_Cliente);
ReportDocument cryRpt = new ReportDocument();
string path = "../../crCliente.rpt";
cryRpt.Load(path);
// Fill the parammeters with values from variable
cryRpt.SetParameterValue("txtIdCli", oCliente.iId);
cryRpt.SetParameterValue("txtNombreCli", oCliente.sNombre);
cryRpt.SetParameterValue("txtNIFCli", oCliente.sNIF);
CrystalReportViewer1.ReportSource = cryRpt; // The crystal report viewer in the form
Я хочу загрузить данные из другой формы, а не из той же формы, что и CrystaReportViewer.
Я пробовал это из другой формы (см. Последнюю строку):
// Get data like select * from cliente with the function
oCliente = GetClienteData("Table_Clientes", Id_Cliente);
ReportDocument cryRpt = new ReportDocument();
string path = "../../crCliente.rpt";
cryRpt.Load(path);
// Fill the parammeters with values from variable
cryRpt.SetParameterValue("txtIdCli", oCliente.iId);
cryRpt.SetParameterValue("txtNombreCli", oCliente.sNombre);
cryRpt.SetParameterValue("txtNIFCli", oCliente.sNIF);
Form1.CrystalReportViewer1.ReportSource = cryRpt; // The crystal report viewer in the form
Показывает сообщение об ошибке
not accessible due to protection level
Я думаю, что это может быть связано с тем, что мне нужно сделать CrystalReportViewer1 в форме, содержащейся для общественности, но я не знаю, как это сделать.
Любая идея ? спасибо.