本文介绍了如何在FastReport中不显示零值并将其移位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在FastReport中有一个问题。我需要制作一个报告,其中我只能看到非零值。例如,我有从SQL查询填充数据的masterdata。在主数据上,我放置了3个描述和值字段。它看起来像这样:

I have one question in FastReport. I need to make a report in which I see only non zero value. For example I have masterdata which fill data from sql query. On masterdata I put 3 description and value fields. Its look like this:

[DATA."DESC1"] DESCRIPTION1 [DATA."VALUE1"] 100
[DATA."DESC2"] DESCRIPTION2 [DATA."VALUE2"] 0
[DATA."DESC3"] DESCRIPTION3 [DATA."VALUE3"] 50

,我想在报告中查看

DESCRIPTION1 100
DESCRIPTION3 50

但现在我看到这样的视图

but now I see view like this

DESCRIPTION1 100

DESCRIPTION3 50

我不想看到空白位置,我需要将第二个位置的第三个位置移动,因为第二个值是null。当然,在我的SQL查询中,还有更多带有值的字段。我尝试找到一些可以解决我问题的循环,但没有找到。我尝试使用属性Visible或ShiftMode,但这无济于事。 Mayby有人知道如何在FastReport中解决此问题。请帮我。

I do not want to see blank position, I need to shift third position on second position because the second value is null. Of course in my SQL query there is much more fields with value. I try to find some loop that solve my problem but I didn`t found. I try to use properties Visible or ShiftMode but it not help for this. Mayby someone knows how to solve this problem in FastReport. Please help me.

推荐答案

作为附加选项,您可以始终使用 OnBeforePrint 事件(在本例中为 MasterData 区域)并组织您的逻辑:

As an additional option, you may always use the OnBeforePrint event (in this case for the MasterData band) and organize your logic:

例如,当 DATA。 VALUE2 为0:

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
var
   top: Extended;                                     
begin
   top := 0;                           
   // TfrxMemoView 1                                                    
   Memo1.SetBounds(Memo1.Left, top, Memo1.Width, Memo1.Height);
   top := top + Memo1.Height;
   // TfrxMemoView 2                                                       
   if (<DATA."VALUE2"> = 0) then begin                                      
      Memo2.Visible := False;                                                      
      end
   else begin
      Memo2.Visible := True;                                                      
      Memo2.SetBounds(Memo2.Left, top, Memo2.Width, Memo2.Height);
      top := top + Memo2.Height;
   end;
   // TfrxMemoView 3                                                       
   Memo3.SetBounds(Memo3.Left, top, Memo3.Width, Memo3.Height);
   top := top + Memo3.Height;
end;

例如,当 DATA。 VALUE1 为0:

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
var
   top: Extended;                                     
begin
   top := 0;                           
   // TfrxMemoView 1                                                    
   if (<DATA."VALUE1"> = 0) then begin                                      
      Memo1.Visible := False;                                                      
      end
   else begin
      Memo1.Visible := True;                                                      
      Memo1.SetBounds(Memo1.Left, top, Memo1.Width, Memo1.Height);
      top := top + Memo1.Height;
   end;
   // TfrxMemoView 2                                                       
   Memo2.SetBounds(Memo2.Left, top, Memo2.Width, Memo2.Height);
   top := top + Memo2.Height;
   // TfrxMemoView 3                                                       
   Memo3.SetBounds(Memo3.Left, top, Memo3.Width, Memo3.Height);
   top := top + Memo3.Height;
end;

这篇关于如何在FastReport中不显示零值并将其移位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 14:55