How I can add TextStyles dynamically?

General TRichView support forum. Please post your questions here
Post Reply
apicito
Posts: 9
Joined: Mon Jul 17, 2006 10:34 am

How I can add TextStyles dynamically?

Post by apicito »

I am constructing Dynamically a calendar with a table in RIchviewedit.
The background an text color of every day is defined in a database and apply them:

Code: Select all

      for d:=1 to topday do
        begin
          table1.Cells[x,d].Clear;
          rvs.TextStyles[1].Color:=Query.fieldbyName('CALENDAR_TEXT').asinteger;
          table1.Cells[x,d].AddNL(inttostr(d),0,1);
          table1.Cells[x,d].Color:=Query.fieldbyName('CALENDAR_BACKG').asinteger;
        end;
background color it's fine. But the text color is always black.

How I can add TextStyles dynamically?[/code]
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You change the Color property of the text style with the index = 1.
But in AddNL method, you use the text style with the index = 0.
The parameters of AddNL:
1) text to display
2) index of text style
3) index of paragraph style (or -1 to continue paragraph)
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

And you do not construct styles dynamically in this code, you change properties of existing style (assuming that you have 2 styles in rvs.TextStyles). So, all text of this style will have color assigned to this style in the last time. You can move the line assigning text style color before the cycle.
apicito
Posts: 9
Joined: Mon Jul 17, 2006 10:34 am

Post by apicito »

How construct styles dynamically?
apicito
Posts: 9
Joined: Mon Jul 17, 2006 10:34 am

Post by apicito »

Solve with Editor2 demo.
Thanks.
Post Reply