Passing MSFlexGrid data to Crystal Report RRS feed

  • Question

  • Hi all,

             I am developing a project in which I have populate a FlexGrid with data in a form. Now, I want to pass the values in the FlexGrid to Crystal report. I am not using any recordset to pass data to crystal report. I have pass some data by using the SetText property of crystal report from the form. But for the data in the FlexGrid, I want to pass the whole data directly as the number of rows in the grid will vary for each query. Moreover, I want to know, whether I should be keeping the Text Object control in the Detail section or any other section.
    Tuesday, July 8, 2008 10:58 AM


  • one possible way to pass your grid data to a crystal report is simply convert the grid's records to a dataset object and pass the dataset to the crystal report.


    DataSet ds = new DataSet() ;
    ds.Tables.Add() ;
    ds.Tables[0].Columns.Add("Column1") ;
    ds.Tables[0].Columns.Add("Column2") ;
    for(int i = 0 ; i < grid.Rows.Count ; i ++)
         object [] row = new object[NumberOfColumns] ;
         row[0] = grid.Rows[i].Cells[0].Text ;
         row[1] = grid.Rows[i].Cells[1].Text ;
         ds.Tables[0].Rows.Add(row) ;


    • Proposed as answer by neonprimetime Tuesday, July 8, 2008 2:03 PM
    • Marked as answer by jack 321 Thursday, July 10, 2008 9:09 AM
    Tuesday, July 8, 2008 2:03 PM