Salve a tutti.
Sto creando un report ed avrei bisogno di stampare dei numeri in colonna allineati a destra.
Ho visto che la soluzione è quella di "disegnarli" dentro dei rettangoli trasparenti.
Ho trovato questo codice (che ho adattato):
codice:
Y = Y + (Font_riga.GetHeight)
e.Graphics.DrawLine(Pens.Black, 10, Y, 810, Y)
Y = Y + (Font_riga.GetHeight)
str = " --- STATISTICHE --- "
e.Graphics.DrawString(str, Font_grass, Brushes.Black, 350, Y)
Y = Y + (Font_riga.GetHeight) * 2
' disegno il rettango che conterr' i dati statistici del tabulato
displayRectangle = New Rectangle(New Point(15, Y), New Size(795, Y + 300))
e.Graphics.DrawRectangle(Pens.Black, displayRectangle)
e.Graphics.DrawString("", Font_riga, Brushes.Black, RectangleF.op_Implicit(displayRectangle), format2)
Y = Y + (Font_riga.GetHeight) * 2
str = "N. % TOTALE % UTILIZZO"
e.Graphics.DrawString(str, Font_grass, Brushes.Black, 250, Y)
Y = Y + (Font_riga.GetHeight) * 2
str = "XXXXXXXXX:"
e.Graphics.DrawString(str, Font_grass, Brushes.Black, 20, Y)
If Not IsDBNull(dts.Tables("stat_righe").Rows(0).Item("RGSt_pres")) Then
displayRectangle = New Rectangle(New Point(360, Y), New Size(62, Font_riga.GetHeight))
e.Graphics.DrawRectangle(Pens.Transparent, displayRectangle)
e.Graphics.DrawString(Format(dts.Tables("Righe_estratte").Rows(0).Item("RGSt_pres"), "#,##0.00"), Font_riga, Brushes.Black, RectangleF.op_Implicit(displayRectangle), format2)
End If
If Not IsDBNull(dts.Tables("stat_righe").Rows(0).Item("RGSu_pres")) Then
displayRectangle = New Rectangle(New Point(530, Y), New Size(62, Font_riga.GetHeight))
e.Graphics.DrawRectangle(Pens.Transparent, displayRectangle)
e.Graphics.DrawString(Format(dts.Tables("Righe_estratte").Rows(0).Item("RGSu_pres"), "#,##0.00"), Font_riga, Brushes.Black, RectangleF.op_Implicit(displayRectangle), format2)
End If
Il problema che quando arrivo alla linea
codice:
e.Graphics.DrawString(Format(dts.Tables("Righe_estratte").Rows(0).Item("RGSt_pres"), "#,##0.00"), Font_riga, Brushes.Black, RectangleF.op_Implicit(displayRectangle), format2)
ottengo questo errore:
"riferimento ad un oggetto non impostato su un istanza di oggetto"
che in tutta sincerità (vedi mia firma) per me non significa quasi nulla ......
Potreste aiutarmi ?
Grazie