Hello, I have all my list box with colors.
Example is the number is < 0 I change to red, but when I try to print the printer show me all in black.
How I can the printer print in red the negative number.
Best Regards
Abimael Lopez
Hello, I have all my list box with colors.
Example is the number is < 0 I change to red, but when I try to print the printer show me all in black.
How I can the printer print in red the negative number.
Best Regards
Abimael Lopez
first off… I will assume it is a COLOR printer?
Second… post the code you use to print the contents of the list box
Yes I use a Color printer, here is the code I use for print
Dim ps As New PrinterSetup
// set the resolution to 600 DPI for printing
ps.MaxHorizontalResolution = 600
ps.MaxVerticalResolution = 600
Dim rpt As New ReportFinancial
Dim g As Graphics
g = OpenPrinterDialog(ps)
If g <> Nil Then
If rpt.Run(ListboxFinancial, ps) Then
If rpt.Document <> Nil Then
rpt.Document.Print(g)
End If
End If
End If
you may want to format all negative numbers first in your styled text and make them red.
I use that code in the listbox,
Event = CellTextPaint
If val(me.Cell(row,2)) < 0 then
g.forecolor = &cFF0000
end if
is work fine inside the listbox, only when I try to print I saw the negative character, but the color is black
when you print, you need to change forecolor before you draw the cell text.
Do you have some example of change forecolor before you draw the cell text.
I did it in the listbox.
yes, but for printing you need to also do it.
If you are using a Xojo Report object, right-click on the field and add a BeforePrinting event handler. In that, check to see if the value is negative and change the color appropriately.
Yes I use the Xojo Report object in this project
the code before printing is
if val(ReportFinancial.FieldTotalDaily.Text) < 0 then
ReportFinancial.FieldTotalDaily.TextColor = &cFF0000
end if
[quote=213492:@Abimael Lopez]Yes I use the Xojo Report object in this project
the code before printing is
if val(ReportFinancial.FieldTotalDaily.Text) < 0 then
ReportFinancial.FieldTotalDaily.TextColor = &cFF0000
end if[/quote]
Is ReportFinancial.FieldTotalDaily the name of the field in the listbox or the field on the Report? If it is the listbox then the code is unlikely to work. I would suggest a simpler form in the BeforePrinting event handler. Something like
If val(me.Text) < 0 Then me.TextColor = &cff0000
This ensures that the value being checked is the one received into the report field.