回答
有一种未记录的方法可以做到这一点。ifrve
是TRichViewEdit
组件并且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;