Page 1 of 1

How I can add TextStyles dynamically?

Posted: Mon Jul 17, 2006 10:50 am
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]

Posted: Mon Jul 17, 2006 2:20 pm
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)

Posted: Mon Jul 17, 2006 3:21 pm
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.

Posted: Tue Jul 18, 2006 7:49 am
by apicito
How construct styles dynamically?

Posted: Tue Jul 18, 2006 9:00 am
by apicito
Solve with Editor2 demo.
Thanks.