使用FastReport,如何将数据库中的Text和Numbers放在以下框中:
|_|_|_|_|_|_|_|_|_|_|所以“萨米”变成了:

同样的数字,我试着用TfrxLineView来做,但我失败了。
发布于 2017-07-01 17:41:21
采取简单的方式:
TfrxMemoView组件,如:

OnPreview事件中,设置代码如下:
过程TForm1.frxReport1Preview(发件人: TObject);var Str : WideString;i: Integer;Mem : TfrxMemoView;开始Str := 'Sami';//或从查询/表(数据库) //获取它,查找TFrxMemoView组件并在其中设置您想要的I := 1至4字符串,请将Mem := frxReport1.FindObject('M'+IntToStr(I))作为TfrxMemoView;Mem.Text := StrI;end;

最新情况:
您还可以以编程方式这样做:
var RT : TfrxBand;
Mem : array [1..100] of TfrxMemoView ;
i : Byte;
Name : WideString;
begin
// Find the band
RT := frxReport1.FindObject('RT') as TfrxBand;
// Set the String
Name := 'DELPHI FAST REPORT';
for I := 1 to Length(Name) do
begin
Mem[i] := TfrxMemoView.Create(RT);
Mem[i].Text := Name[i];
Mem[i].Font.Style := [fsBold];
Mem[i].Frame.Width := 2;
Mem[i].Height := 20;
Mem[i].AutoWidth := False;
Mem[i].HAlign := haCenter;
Mem[i].Frame.Typ := [ftLeft , ftBottom , ftRight];
Mem[i].Width := 20;
if i =1 then
Mem[i].Left := 0
else
Mem[i].Left := Mem[i-1].Left + 5 + 15;
end;
frxReport1.ShowReport();
end;结果是:

发布于 2017-07-01 12:42:27
没有现成的控件可以按您的要求在方框中显示字符。因此,你需要自己在你选择的画布上画这个。
下面是如何在TPaintBox中执行此操作的示例,pbText在这里是演示表单的string字段,并保存要显示在画图框中的文本:
procedure TForm17.PaintBox1Paint(Sender: TObject);var
i, n, x, y: integer;
siz: TSize;
pb: TPaintBox;
begin
n := 10; // character cells
pb := Sender as TPaintBox;
siz := pb.Canvas.TextExtent('Wp');
// draw character cells
x := 4; y := siz.cy+2;
for i := 0 to n do
begin
pb.Canvas.MoveTo(i * siz.cx + x, 0);
pb.Canvas.LineTo(i * siz.cx + x, y);
end;
pb.Canvas.MoveTo(x, y);
pb.Canvas.LineTo(n * siz.cx + 4, y);
// draw characters horizontally in center of box
for i := 1 to Length(pbText) do
begin
x := (4 + (i-1)*siz.cx + (siz.cx - pb.Canvas.TextWidth(pbText[i])) div 2);
y := 0;
pb.Canvas.TextOut(x, y, UpperCase(pbText[i])); // force upcase
// pb.Canvas.TextOut(x, y, pbText[i]); // or don't
end;
end;并利用它
procedure TForm17.Button1Click(Sender: TObject);
begin
pbText := 'Sami Wiim';
PaintBox1.Invalidate;
end;

发布于 2017-07-01 17:15:33
非常简单而且有点丑陋的方法来做这件事。
-place这样的文本对象:TEST_STR;
-set文本风格以下划线;
2.在德尔菲
-make函数将字符串转换为格式化字符串。例如:
输入:SAMI
输出:| S | A | M | I |
-in OnGetValue事件的FastReport调用此函数:
procedure TMainForm.frxReport1GetValue(const VarName: string;
var Value: Variant);
begin
if VarName = 'TEST_STR' then Value := MyFunctionToFormatStr('SAMI');
end;就这样。
结果如下:

https://stackoverflow.com/questions/44850463
复制相似问题