PrintDBGridEh->SetSubstitutes应该怎么用???

ntahua 2008-09-12 08:47:32
想用PrintDBGridEh来打印表格,标题内容不固定,所以想设置参数来传递。

DELPHI里是这样:
PrintDBGridEh1.SetSubstitutes(['%[Today1]',FormatDateTime('yyyy"年"mm"月"',Now)

但是在BCB里用法完全不一样
TPrintDBGridEh::SetSubstitutes(const TVarRec *,const int)

郁闷了一天了,到底该怎么用??


或者BeforeGridText能不能设置字体,居中还是居左???
...全文
311 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
ntahua 2008-09-17
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 keiy 的回复:]
是的,我也曾出现过内存错,不过后来发现是我的BeforeGridText中的%[Today1]写错了
查你的BeforeGridText,一定要有%[Today1],且不能有其它的%[???]
另外在测试中还发现一个问题,那就是在%[Today1]后面所有的字串都无法打印
另外,我的程序是写在
void __fastcall TForm1::PrintDBGridEh1BeforePrint(TObject *Sender)
{
PrintDBGridEh1->SetSubstitutes(ARRAYOFCONST(("%[Today1]",FormatDateTime("yyyy'年'mm'月'",Now()))))…
[/Quote]

试了不行。还是内存出错。
看来是我的人品不好。打算改用别的东西打印了。
柯本 2008-09-17
  • 打赏
  • 举报
回复
可能是你的ehlib本身的问题(ehlib有很多版本,我用的是老的EhLib v3.4 在盒子上下的)
柯本 2008-09-16
  • 打赏
  • 举报
回复
是的,我也曾出现过内存错,不过后来发现是我的BeforeGridText中的%[Today1]写错了
查你的BeforeGridText,一定要有%[Today1],且不能有其它的%[???]
另外在测试中还发现一个问题,那就是在%[Today1]后面所有的字串都无法打印
另外,我的程序是写在
void __fastcall TForm1::PrintDBGridEh1BeforePrint(TObject *Sender)
{
PrintDBGridEh1->SetSubstitutes(ARRAYOFCONST(("%[Today1]",FormatDateTime("yyyy'年'mm'月'",Now()))));

}

ntahua 2008-09-16
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 yumikoo 的回复:]
单步下看看,那一步?
[/Quote]
看了,就是这一步
PrintDBGridEh1->SetSubstitutes(ARRAYOFCONST(("%[Today1]",FormatDateTime("yyyy'年'mm'月'",Now()))));
ntahua 2008-09-16
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 keiy 的回复:]
经测试:
PrintDBGridEh1->SetSubstitutes(ARRAYOFCONST(("%[Today1]",FormatDateTime("yyyy'年'mm'月'",Now()))));

PrintDBGridEh1.SetSubstitutes(['%[Today1]',FormatDateTime('yyyy"年"mm"月"',Now)

完全等同
(上面的FormatDateTime写错了)
[/Quote]

keiy,你测试真的通过了??难道是我系统的问题吗?
yumikoo 2008-09-16
  • 打赏
  • 举报
回复
单步下看看,那一步?
ntahua 2008-09-16
  • 打赏
  • 举报
回复
内存地址出错,晕死了。
---------------------------
Debugger Exception Notification
---------------------------
Project TEST.exe raised exception class EAccessViolation with message 'Access violation at address 00624BB5 in module 'TEST.exe'. Read of address 015A4CF7'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
ntahua 2008-09-16
  • 打赏
  • 举报
回复
内存地址出错,晕死了。
---------------------------
Debugger Exception Notification
---------------------------
Project TEST.exe raised exception class EAccessViolation with message 'Access violation at address 00624BB5 in module 'TEST.exe'. Read of address 015A4CF7'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
ntahua 2008-09-13
  • 打赏
  • 举报
回复
谢谢keiy,上班了我试试
柯本 2008-09-12
  • 打赏
  • 举报
回复
经测试:
PrintDBGridEh1->SetSubstitutes(ARRAYOFCONST(("%[Today1]",FormatDateTime("yyyy'年'mm'月'",Now()))));

PrintDBGridEh1.SetSubstitutes(['%[Today1]',FormatDateTime('yyyy"年"mm"月"',Now)

完全等同
(上面的FormatDateTime写错了)
柯本 2008-09-12
  • 打赏
  • 举报
回复
按delphi的,应该这样写:

PrintDBGridEh1->SetSubstitutes(ARRAYOFCONST(("%[Today1]",FormatDateTime("yyyy年mm月",Now()))));
ntahua 2008-09-12
  • 打赏
  • 举报
回复
楼上的,你发的是DELPHI里的代码,在BCB里行不通。
即使改成 TPrintDBGridEh->SetSubstitutes(["%[日期]",DateToStr(Now)]),这么用报“[C++ Error] main.cpp(2474): E2188 Expression syntax”。


求BCB中的代码例子。
御剑逍遥恪 2008-09-12
  • 打赏
  • 举报
回复
你可以用dbgrideh控件
这个控件有一个直接打印函数
可直接打印的

pdbgPscnt.DBGridEh := dgProperty;
pdbgPscnt.SetSubstitutes(['%[日期]',DateToStr(Now)]);
pdbgPscnt.Preview;
御剑逍遥恪 2008-09-12
  • 打赏
  • 举报
回复
TPrintDBGridEh.SetSubstitutes(['%[日期]',DateToStr(Now)]);
参照这个~试试~~

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧