TRichViewEdit段号

时间:2012-07-26 00:13:32

标签: delphi properties delphi-xe2 paragraph

TRichViewEdit组件中有大量属性可以查找给定段落的大多数属性。例如,您可以轻松判断段落是否使用编号,使用的编号类型,是否以特定数字开头编号或是前一段的延续等等。

但是,我无法找到确定正在使用的段落编号的属性或方法。例如:

A. some text
B. more text
C. etc

我无法告诉some text是段落号Amore text是号码B,而且"等等#34}是' C'。如果我也可以访问数字值,例如' 1',' 2'或者' 3'那将是没关系的。

有没有人有TRichViewEdit的经验并且知道如何获得段落编号值?

1 个答案:

答案 0 :(得分:3)

答案

有一种无证的方法可以做到这一点。如果rveTRichViewEdit组件,ItemNo是带编号的段落的项目编号的ID:

use
  RVMarker;

TRVMarkerItemInfo(rve.RVData.GetItem(ItemNo)).Counter; // paragraph number as int
TRVMarkerItemInfo(rve.RVData.GetItem(ItemNo)).DisplayString; // displayed paragraph number

实施例

use
  RVMarker, TypInfo;
---
var
  i, lno, ll, sf: Integer;
  usf: Boolean;
  rvmii: TRVMarkerItemInfo;
  pi: TParaInfo;
  s: string;
begin
  for i := 0 to rve.ItemCount - 1 do
  begin
    if rve.RVData.GetItemStyle(i) = rvsListMarker then
    begin
      pi := rve.Style.ParaStyles.Items[rve.GetItemPara(i)];
      rve.GetListMarkerInfo(i, lno, ll, sf, usf);
      s := GetEnumName(TypeInfo(TRVListType), Ord(rve.Style.ListStyles.Items[lno].Levels[ll].ListType));
      rvmii := TRVMarkerItemInfo(rve.RVData.GetItem(i));

      ShowMessage(
        Concat(
          'Paragraph Info',                                      #13#10,
          '---------------------------------',                   #13#10,
          #09'OutlineLevel:',    #09, IntToStr(pi.OutlineLevel), #13#10,
          #09'ID:',           #09#09, IntToStr(pi.ID),           #13#10,
          #09'Index:',        #09#09, IntToStr(pi.Index),        #13#10,
                                                                 #13#10,
          'Marker Info',                                         #13#10,
          '---------------------------------',                   #13#10,
          #09'ListNo:',       #09#09, IntToStr(lno),             #13#10, // can also use 'rvmii.ListNo'
          #09'ListLevel:',       #09, IntToStr(ll),              #13#10, // can also use 'rvmii.Level'
          #09'StartFrom:',       #09, IntToStr(sf),              #13#10, // can also use 'rvmii.StartFrom'
          #09'UseStartFrom:',    #09, BoolToStr(usf),            #13#10, // can also use 'rvmii.Reset'
          #09'Counter:',         #09, IntToStr(rvmii.Counter),   #13#10,
          #09'DisplayType:',     #09, s,                         #13#10,
          #09'DisplayString:',   #09, rvmii.DisplayString,       #13#10,
                                                                 #13#10,
          'ItemText',                                            #13#10,
          '---------------------------------',                   #13#10,
          rve.GetItemText(i+1),                                  #13#10  // next item is text for para #
        )
      );
    end;
  end;
end;