Ciao,
non riesco a stampare un grafico popolato da un DataTable.
Dopo svariate ricerche ho notato che molti usano chart1.Printing
ma a me non riconosce proprio il metodo "Printing"
infatti mi sottolinea chart1.Printing dicendo: "'Printing' non è un membro di 'System.Web.UI.DataVisualization.Charting.Chart'".
Questo il mio codice per stampare:
codice:
Protected Sub bttPrintChart_Click(sender As System.Object, e As System.EventArgs) Handles bttPrintChart.Click
Dim pd As New System.Drawing.Printing.PrintDocument()
' Add the event handler, and then print
AddHandler pd.PrintPage, AddressOf pd_PrintPage
' Print the document
pd.Print()
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
' Create and initialize print font
Dim printFont As New System.Drawing.Font("Arial", 10)
' Create Rectangle structure, used to set the position of the chart
Dim myRec As New System.Drawing.Rectangle(10, 30, 150, 150)
' Draw a line of text, followed by the chart, and then another line of text
ev.Graphics.DrawString("Line before chart", printFont, Brushes.Black, 10, 10)
chart1.Printing.PrintPaint(ev.Graphics, myRec)
ev.Graphics.DrawString("Line after chart", printFont, Brushes.Black, 10, 200)
End Sub
Ho provato anche mettendo il grafico all'interno di un Panel e stamparmi il panel, ma del grafico stampa solo i bordi e non il contenuto