Click to See Complete Forum and Search --> : help!!! for printing all the records of datagrids
SHIVPREET2K1
Sep 8th, 2005, 05:37 AM
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
Strider
Sep 8th, 2005, 06:24 AM
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
SHIVPREET2K1
Sep 8th, 2005, 07:50 AM
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
Strider
Sep 8th, 2005, 08:14 AM
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()
SHIVPREET2K1
Sep 9th, 2005, 12:08 AM
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
Strider
Sep 9th, 2005, 03:06 AM
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()
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.