Results 1 to 6 of 6

Thread: help!!! for printing all the records of datagrids

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    help!!! for printing all the records of datagrids

    Hi friends

    I m createing a project in which i am dynamically binding data to a datagrid. what i need is to print the data in datagrid in a report format. but i do not know that how to do it.

    Plz help me, its urgent


    Thanks in advance


    Shivpreet2k1

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: help!!! for printing all the records of datagrids

    it depends on the type of report you want to create.

    if you just want to display data in the form of database tables
    write the data to a csv(comma separated) file

    if you want to create a report i'd use the string builder and write it to txt file
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: help!!! for printing all the records of datagrids

    DEAR FRIEND
    IWANT TO GET THE PRINT IN THE TABULAR FORMAT. COULD YOU PROVIDE ME ANY EXAMPLE. SO THAT I MAY GET THE CLEAR IDEA OF THE CODE THAT I SHOULD USE


    BYE

    Shivpreet2k1

  4. #4
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: help!!! for printing all the records of datagrids

    Dim l_sWriter As New StreamWriter("mytextfile.txt")
    Dim l_outLine As String

    Dim l_noRows As Integer = datagrid1.visiblerowcount
    Dim i As Integer
    For i=0 to l_rows - 1
    l_outLine = datagrid1.item(0,0) & vbTab & datagrid1.item(0,1) & vbtab & datagrid1.item(0,2)
    l_sWriter.WriteLine(l__outLine )
    l__outLine = ""
    Next

    l_sWriter.Close()
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: help!!! for printing all the records of datagrids

    Dear friend

    Thanks for your code but it is giving me syntex error. Do i need to include a refernce for that

    Thanks in advance

    Shivpreet2k1

  6. #6
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: help!!! for printing all the records of datagrids

    i just wrote that in the forum without testing it so there are bound to be errors...


    this is it without errors

    Dim l_sWriter As New System.IO.StreamWriter("mytextfile.txt")
    Dim l_outLine As String

    Dim l_noRows As Integer = datagrid1.visiblerowcount
    Dim i As Integer
    For i = 0 To l_noRows - 1
    l_outLine = datagrid1.Item(0, 0) & vbTab & datagrid1.Item(0, 1) & vbTab & datagrid1.Item(0, 2)
    l_sWriter.WriteLine(l_outLine)
    l_outLine = ""
    Next

    l_sWriter.Close()
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width