Zeb Muhammad

Zeb Muhammad

  • NA
  • 67
  • 18.2k

Transfer Data from DGV of Form1 to Crystal Report of Form2

Sep 13 2017 12:11 PM
Dear Frien,
I am working in C# .... I nedd Help/.]
I created FROM1 which has DATAGRIDVIEW and fetched data from Database,and on the Form2 has Crystal Report Design , how can transfer data from Datagrideview of FORM1 to Crystal Report of FORM2..........
Code is bellow-:
private void btn_CrtRep_Click(object sender, EventArgs e)
{
{
pur_DS ds = new pur_DS();
int file = dataGridView1.Rows.Count;
for (int i = 0; i <= file - 2; i++)
{
ds.Tables[0].Rows.Add
(new object[]
{
dataGridView1[0,i].Value.ToString(),
dataGridView1[1,i].Value.ToString(),
dataGridView1[2,i].Value.ToString(),
dataGridView1[3,i].Value.ToString(),
dataGridView1[4,i].Value.ToString(),
dataGridView1[5,i].Value.ToString(),
dataGridView1[6,i].Value.ToString(),
dataGridView1[7,i].Value.ToString(),
dataGridView1[8,i].Value.ToString(),
dataGridView1[9,i].Value.ToString(),
});
}
form2 frm = new form2();
ReportDocument crCR = new ReportDocument();
crCR.Load("D:\\Personal\\MMS\\testCR\\testCR\\PurRep.rpt");
crCR.SetDataSource(ds);
frm.crystalReportViewer1.ReportSource = crCR;
frm.crystalReportViewer1.Refresh();
frm.Show();
}

Answers (1)