Bullet point list

General TRichView support forum. Please post your questions here
Post Reply
mwsta
Posts: 2
Joined: Thu Apr 03, 2025 11:32 am

Bullet point list

Post by mwsta »

I'm trying to make a bullet point list in C++Builder using this:

Code: Select all

ReportRichView->RichViewEdit->AddNL("My list:", RV_TEXT, RV_TEXT);
ReportRichView->RichViewEdit->SetListMarkerInfo(-1, RV_BULLET_LIST, 0, 1, 1, false);
ReportRichView->RichViewEdit->AddNL("text", RV_LIST_ITEM_TEXT, -1); 
ReportRichView->RichViewEdit->SetListMarkerInfo(-1, RV_BULLET_LIST, 0, 1, 1, false);
ReportRichView->RichViewEdit->AddNL("text", RV_LIST_ITEM_TEXT, -1); 

Code: Select all

// styles for RV_LIST_ITEM_TEXT:
TFontInfo* finfo = ReportRichView->RichViewEdit->Style->TextStyles->Add();
finfo->StyleName = "List item text";
finfo->FontName = "Arial";
finfo->Size = 12;
finfo->Color = clBlack;
TParaInfo* pinfo = ReportRichView->RichViewEdit->Style->ParaStyles->Add();
pinfo->StyleName = "List item text";
pinfo->Alignment = rvaLeft; // rvaLeft, rvaRight, rvaCenter, rvaJustify
pinfo->LineSpacing = 0.5;
pinfo->SpaceBefore = 1;
pinfo->SpaceAfter = 1;

// bullet point list RV_BULLET_LIST:
TRVListInfo* linfo = ReportRichView->RichViewEdit->Style->ListStyles->Add();
TRVListLevel* llevel = linfo->Levels->Add();
llevel->ListType = rvlstBullet;
llevel->Font->Name = "Arial";
llevel->Font->Size = 12;
llevel->Font->Color = clBlack;
llevel->FirstIndent = 0;
llevel->LeftIndent = 12;
But I always get an odd spacing between the items. I tried to change SpaceBefore and SpaceAfter but that didn't change anything. How can I get rid of the spacing?

Image
Attachments
Screenshot 2025-04-03 135228.jpg
Screenshot 2025-04-03 135228.jpg (4.26 KiB) Viewed 3834 times
Sergey Tkachenko
Site Admin
Posts: 17761
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Bullet point list

Post by Sergey Tkachenko »

Please check which paragraph style is used in your code.
In your code sample, the following paragraph styles are used:
1. ParaStyles->Items[RV_TEXT]
It is the last parameter of ReportRichView->RichViewEdit->AddNL("My list:", RV_TEXT, RV_TEXT);
It's strange that the same constant RV_TEXT are used both as an index in TextStyles (2nd parameter) and as an index in ParaStyles (3rd parameter).
2. ParaStyles->Items[1]
It is the last but one parameter of ReportRichView->RichViewEdit->SetListMarkerInfo(-1, RV_BULLET_LIST, 0, 1, 1, false);
It's strange that a constant is not used.

Probably you use not the paragraph style defined in this code, but other paragraph styles.

As for your paragraph style.
You assign pinfo->LineSpacing = 0.5;
But pinfo->LineSpacing is an integer value measured in % (assuming that pinfo->LineSpacingType has the default value: rvlsPercent).
So, your code simply assigns 0 to LineSpacing.
TRichView ignores line spacing less than 50%, so this paragraph style has the default single line spacing (the same as LineSpacing == 100).
mwsta
Posts: 2
Joined: Thu Apr 03, 2025 11:32 am

Re: Bullet point list

Post by mwsta »

Thank you Sergey! Your response solved the problem. I had not understood that the fith paramter of SetListMarkerInfo() refers to the paragraph style (I copied it from code I found in the web). With this modification it now works (yes, the wrong paragraph style was used):

Code: Select all

ReportRichView->RichViewEdit->SetListMarkerInfo(-1, RV_BULLET_LIST, 0, 1, RV_TEXT, false);
I used the same constants for text and paragraph styles, since I wanted to have each paragraph to have a particular text style, but you are right, it's more consistent to keep them separate. And I see I missunderstood the line spacing.

Thank you!
Post Reply