locked
print all of datagridview items RRS feed

  • Question

  • Hello.

    i already created a crystal report.

    now i want send all of the datagridview items one by one into it then use crystal report viewer to print data.

    i can print datagridview current cell without error but i dont know how can print all cells of the datagridview.

    Thanks.

    Wednesday, April 4, 2012 7:45 AM

Answers

All replies

  • Refer here for info: http://social.msdn.microsoft.com/Forums/eu/vscrystalreports/thread/8dc49602-7f05-41b1-90e9-1bdd501c77b6

    Mitja

    • Marked as answer by Jason Dot Wang Friday, April 6, 2012 1:25 AM
    • Unmarked as answer by Bouki Friday, April 6, 2012 1:02 PM
    • Marked as answer by Jason Dot Wang Tuesday, April 17, 2012 1:27 AM
    Wednesday, April 4, 2012 8:04 AM
  • Thanks mitja.

    your reference is good but i need more detail.

    i want follow this method:

    1. Create a crystal report with all the columns available in the datagridview.  If some columns are calculated and populated by you then you can use some thing 
        like this (select eno, ename, ebasic, 0 as eta, 0 as eda, 0 as ehra from temporarytable) assuming eta, eda, ehra are calculated by you.

    2. In the program create a datatable object.  Manually add all the columns in the datagridview to the datatable object.

    3. Manually add all rows in datagridview to the datatable.

    4. Assign the datatable object as datasource to crystal report.

    in my print button i use this code to print one of the datagridview rows:

            private void buttonPrint_Click(object sender, EventArgs e)
            {
                try
                {
                    Intial();
                    CreateLog();
                    IntialCrystalReportViewer();
                }
                catch (Exception ex) { MessageBox.Show(ex.ToString());}
    
            }

    Wednesday, April 4, 2012 8:28 AM
  • i have a datagridview which contains the user ides. i use this  ides to select the users information for creating some kind of report.
    now i  want print this report.
    i can do it when user select one of datagridview rows but i need do it for all of the datagridview rows.
    for example user selected all of the datagridview rows then i should create a report for each rows selected then print all of them with one click.
    • Edited by Bouki Wednesday, April 4, 2012 11:55 AM
    Wednesday, April 4, 2012 9:00 AM
  • Hi Bouki,

      Here are some sample code I think it is useful for you. You can refer to it:

      http://msdn.microsoft.com/en-us/library/ms227408(v=vs.80).aspx

      Hope it helps you.

     Sincerely,

     Jason Wang


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 17, 2012 1:26 AM