change font color to white depending on a value

edited December 2017 in FastReport .NET
I have been trying Fast Reports for a few days so far, but I have not been able to do this:
I need to change the font color to white for two texbobjects and a lineobject depending on the value of the second textobject which text property is : [QUOT_CC.TOT_DISC], this is the total discount of a quotation in my database. If the value is zero then change the font color to white so nothing is printed and our customer does not see: 'Commercial 'Discount 0.00' neither a line below that figure, what follows is the tax and a final total.
Your help is much appreciated. Thanks
Bob

Within the Public Class ReportScript I have written for the events BeforePrint these code lines:

'the label Commercial 'Discount
Private Sub Text28_BeforePrint(ByVal sender As Object, ByVal e As EventArgs)
If Val (Text16.Value) = 0 then
Text28.Visible = False
Text28.TextColor = Color.White
else
Text28.Visible = True
Text28.TextColor = Color.Black
End If
End Sub

'the total discount 0.00
Private Sub Text16_BeforePrint(ByVal sender As object, ByVal e As EventArgs)
If Val (Text16.Value) = 0 then
Text16.Visible = False
Text16.TextColor = Color.White
else
Text16.Visible = True
Text16.TextColor = Color.Black
End If
End Sub


'the line _________________
Private Sub Line3_BeforePrint(ByVal sender As object, ByVal e As EventArgs)
If Val (Text16.Value) = 0 then
Line3.Visible = False
Line3.Border.Color = Color.white
else
Line3.Visible = True
Line3.Border.Color = Color.Black
End If
End Sub


and sometimes it works, nothing is printed for those objects, but some other times it does not work (the label, the discount 0.00, and the line are printed).
Thanks again !

Comments

  • edited 9:24PM
    use 'Report.GetColumnValue' function :
    decimal value = (decimal)Report.GetColumnValue("QUOT_CC.TOT_DISC");
    if (value == 0)
    {
       Text16.Visible = false;
       Text16.TextColor = Color.White;
    }
    else
    {
       Text16.Visible = true;
       Text16.TextColor = Color.Black;
    }
    
  • edited 9:24PM
    ipong thanks a lot it works wonderfully !!!

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.