473,508 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print Datagridview

OuTCasT
374 Contributor
Can some one please tell me if this is the correct way to print data from a gridview because it gives me an error

Expand|Select|Wrap|Line Numbers
  1. Private PrintGrid As DataGridViewPrint
  2. Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
  3. Dim fpr As New frmPrint()
  4. With fpr
  5. .Title = DataGridView1.CaptionText
  6. .ShowDialog()
  7. If .Result > 0 Then
  8. PrintGrid = New DataGridViewPrint(PrintDocument1, DataGridView1, .bBlackWhite)
  9. PrintGrid.PrintTitle = .bTitle
  10. PrintGrid.Title = .Title
  11. Select Case .Result
  12. Case 1 ' Print
  13. ' The Print method prints the DataGridView without using a print dialog.
  14. ' Use a PrintDialog when you want to offer the user the ability to choose print settings.
  15. If PrintDialog1.ShowDialog() = DialogResult.OK Then PrintDocument1.Print()
  16. Case 2 ' Page Setup
  17. PageSetupDialog1.ShowDialog()
  18. Case 3 ' Preview
  19. PrintPreviewDialog1.Icon = fpr.Icon
  20. PrintPreviewDialog1.ShowDialog()
  21. End Select
  22. End If
  23. End With
  24. End Sub
Jan 29 '08 #1
1 2564
radcaesar
759 Recognized Expert Contributor
Reply with the exact error no and message
Jan 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
12324
by: Sharon | last post by:
Hi All. Is there a way to print the content of DataGridView, Without using Graphics.DrawString on every row? Thanks, Sharon.
3
10024
by: Arno Au | last post by:
Hi, how can I print the content of a datagridview in vb 2005? thanks for answers, Arno
3
7865
by: Marc | last post by:
Hallo, can someone tell me, how i could print a datagridview? I found in the whole net nothing :( bye
1
3880
by: vanderlej | last post by:
does anyone have code for PrintPreview and print of DataGridView? thanks
0
1836
by: Scotty | last post by:
Hi, Hope someone can help me I have a datagridview sith data Code below works fine if I print the data if there is only 1 page (without using '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! If...
2
2647
by: Scotty | last post by:
Hi, Hope someone can help me I have a datagridview I want to print Code below works fine if I print the data if there is only 1 page (without using hasmore pages...
7
1802
devikacs
by: devikacs | last post by:
i am new to C# .net. i am trying to print the contents of a sql table on a form using datagridview. i've first printed the values of a select command on the datagridview. on clicking a button, the...
0
1319
by: murali007 | last post by:
Hi, i have to print datagridview content and some text using c# in windows application.. iam able to print datagridview print seperate and text seperate print .. but iam not able to print both...
1
1761
by: gleave | last post by:
Hi, below is the code i got to print a datagridview, the trouble is it also prints visible columns which i don't want to be printed. Does anyone have any ideas on how i could change the code so it...
0
7229
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.