locked
How to print Datagrid in C# ?

    Question

  • hi
    i found an article in codeproject as DataGridPrinter that print datagrid good. but it has written with VB.Net and i want it in csharp. when i create dll in VB.Net and i use it in c# the following error shown me :

    Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.DataTable'

    and when i set Datagrid1.DataSource = ds1.Tables["Table1"];  the following error shown me :

    //in Line 374
    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    how to solve my problem and do you have a other class that print datagrid in C# with header and footer ?
    thanks ..

    Thursday, October 05, 2006 6:35 PM

All replies

  • Hi Hamed

    If you go back to Code Project an do a search for PrintDataGridView Class you will find an example app and the class used to do the printing it works well and it is in C# .

    Hope this helps Barry

    Saturday, November 04, 2006 11:26 PM
  • index-was-out-of-range-must-be-nonnegative-and-less-than-the-size-of-the-collection-error

    when i am going to previous page in gridview


           ========== TxtEmpid.Text = GridView1.RowsIdea.Cells[1].Text;=========
                   

    Friday, January 25, 2008 5:44 AM