在用EHLIB中处理报表时,要动态设置printdbgrideh的beforegridtext的rich text中预设对象的文本字体大小,请问如何实现?或者谁有rich text的资料,也可以给我。一样给分!

解决方案 »

  1.   

    procedure TRichStrEditDlgEh.FormCreate(Sender: TObject);
    begin
      GetFontNames;
      SetupRuler;
      SelectionChange(Self);  CurrText.Name := DefFontData.Name;//关键,设置默认字体
      CurrText.Size := -MulDiv(DefFontData.Height, 72, Screen.PixelsPerInch);//关键,设置默认字体大小
    end;
    看懂了没有?直接打开源码文件,修改我标注为关键的两句,重新编译安装Ehlib即可。
      

  2.   

    对了,文件名为RichEdEh.pas,你搜索一下Source目录就会发现。
      

  3.   

    PrintDBGridEh1.DBGridEh := DBGridEh1;
      PrintDBGridEh1.SetSubstitutes(['%[Today]',DateToStr(Now)]);
       //PrinterPreview.Orientation := poPortrait;    //       PrinterPreview.Orientation := poLandscape;    //
      PrintDBGridEh1.Preview;
    我试了,没有呀还是改不了。我想用的就是PrintDBGridEh1.SetSubstitutes,我看过它的代码,它会查找到预先设好的字符,然后替换,不过它只表示最后的那个预设字符。另外,如果是字母,大小可以用RICH编辑器来控制,可是一放入汉字就不受控制了。 forgot(忘记forgot2000),这个方法我试过了,不大管用
    我是这样做的:
    CurrText.Name := '宋体';//关键,设置默认字体
      CurrText.Size := -MulDiv(7, 72, Screen.PixelsPerInch);//
      

  4.   

    你提问题应该提清楚,我的方法是针对你原先提的问题的,至于SetSubstitutes,则是另外一码事了。你想更改SetSubstitutes中的字体,就在PrnDbgEh.pas中找
    function TPrintDBGridEh.GridTextReplace(RichStrings: TStrings;
      const SearchStr, ReplaceStr: string; StartPos, Length: Integer;
      Options: TSearchTypes; ReplaceAll: Boolean): Integer;
    begin
      Result := -1;
      with TRichEditStrings(RichStrings) do
      begin
        while True do
        begin
          Result := RichEdit.FindText(SearchStr, StartPos, Length, Options);
          if Result <> -1 then
          begin
            RichEdit.SelStart := Result;
            RichEdit.SelLength := System.Length(SearchStr);
            RichEdit.SelText := ReplaceStr;
            RichEdit.Font.Name:=....//在这里加上你的代码
          end;
          if not ReplaceAll or (Result = -1) then Break;
        end;
      end;
    end;
      

  5.   

    RichEdit.font.Name:='宋体';
    RichEdit.font.size:=9;这样RICHEDIT的值全变成宋体九号了,有没有方法可以让第二行或是某一行的值变成想要的字体?