Code: Select all
const Indent = 24;
begin
RVStyle1.ListStyles.Clear;
// adding ListStyle[0] with 4 levels
with RVStyle1.ListStyles.Add do begin
with Levels.Add do begin
ListType := rvlstUpperAlpha;
FormatString := '%0:s.';
LeftIndent := Indent*1;
MarkerIndent := Indent*0;
FirstIndent := 0;
Font.Assign(RVStyle1.TextStyles[0]);
end;
with Levels.Add do begin
ListType := rvlstDecimal;
FormatString := '(%1:s)';
LeftIndent := Indent*2;
MarkerIndent := Indent*1;
FirstIndent := 0;
Font.Assign(RVStyle1.TextStyles[0]);
end;
with Levels.Add do begin
ListType := rvlstDecimal;
FormatString := '%2:s.';
LeftIndent := Indent*3;
MarkerIndent := Indent*2;
FirstIndent := 0;
Font.Assign(RVStyle1.TextStyles[0]);
end;
with Levels.Add do begin
ListType := rvlstBullet;
FormatString := '-';
LeftIndent := Indent*4;
MarkerIndent := Indent*3;
FirstIndent := 0;
Font.Assign(RVStyle1.TextStyles[0]);
end;
end;
// adding ListStyle[1] with 1 level
with RVStyle1.ListStyles.Add do begin
with Levels.Add do begin
ListType := rvlstBullet;
FormatString := '-';
LeftIndent := Indent*2;
MarkerIndent := Indent*1;
FirstIndent := 0;
Font.Assign(RVStyle1.TextStyles[0]);
end;
end;
// Building doc
with RichViewEdit1 do begin
Clear;
SetListMarkerInfo(-1, 0, 0, 1, 0, False);
Add('1st Level Text 1', 0);
SetListMarkerInfo(-1, 0, 1, 1, 0, False);
Add('2nd Level Text 1', 0);
SetListMarkerInfo(-1, 0, 1, 1, 0, False);
Add('2nd Level Text 2', 0);
SetListMarkerInfo(-1, 0, 2, 1, 0, False);
Add('3rd Level Text 1', 0);
SetListMarkerInfo(-1, 0, 2, 1, 0, False);
Add('3rd Level Text 2', 0);
SetListMarkerInfo(-1, 0, 3, 1, 0, False);
Add('4th Level Text 1', 0);
AddNL('"Additional text which is 1st Level Text 1 too"'+
' - not possible, this paragraph does not have numbering, '+
'but the numbering below will be continued', 0, 0);
SetListMarkerInfo(-1, 0, 0, 1, 0, False);
Add('1st Level Text 2', 0);
AddNL('"Additional 1st Level Text 2"'+
' - not possible, this paragraph does not have numbering, '+
'but the numbering below will be continued', 0, 0);
SetListMarkerInfo(-1, 0, 0, 1, 0, False);
Add('1st Level Text 3', 0);
SetListMarkerInfo(-1, 1, 0, 1, 0, False);
Add('unordered List Item 1', 0);
SetListMarkerInfo(-1, 1, 0, 1, 0, False);
Add('unordered List Item 2', 0);
Format;
end;
end;
It's not necessary to create list styles in code, they can be created at designtime in the Object Inspector