List Index out of bounds Error

General TRichView support forum. Please post your questions here
Post Reply
bswift
Posts: 37
Joined: Thu Sep 15, 2005 8:26 pm

List Index out of bounds Error

Post by bswift »

Hello all,

I have a routine that I have been using to format different strings as I added then to a TRichViewEdit. Up until I upgraded my Richview stuff it worked perfect and as a matter of fact, it still does, but only when run outside of the IDE. Here is the code and the error is noted:

Code: Select all

procedure TMain.ChangeFonts(TheFont,TheSize,TheColor,TheBColor,B,I,U,P:string);
begin
   with RVS.TextStyles.Add do
    begin
     FontName := TheFont;
     Size := strtoint(TheSize);
     Color:= stringtocolor(TheColor);
     BackColor:=stringtocolor(TheBColor);
     if B='1' then
     Style := Style+[fsbold] else
     Style := Style-[fsbold];
     if I='1' then
     Style := Style+[fsitalic] else
     Style := Style-[fsitalic];
     if U='1' then
     Style := Style+[fsunderline] else
     Style := Style-[fsunderline];
     RVE.ApplyTextStyle(RVS.TextStyles.Count-1);  <-----Exception here EList Error "List Index out of bounds (-1)
     ts:=RVS.TextStyles.Count-1;
     with RVS.ParaStyles.Add do
     begin
     if P='0' then Alignment:=rvaLeft;
     if P='1' then Alignment:=rvaCenter;
     if P='2' then Alignment:=rvaRight;
     RVE.ApplyParaStyle(RVS.ParaStyles.Count-1);
     ps:=RVS.ParaStyles.Count-1;
  end;
end;
end;
If anyone can tell me what is going on, please let me know.

Thanks,

Bruce
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be RVE is not formatted before calling ApplyTextStyle?
bswift
Posts: 37
Joined: Thu Sep 15, 2005 8:26 pm

Problem fixed

Post by bswift »

Sergey,

You are correct. I have been using this code for years and have had no problem with it. But, this has fixed it. Thanks so much and thanks for working so hard to produce a great set of components.

Blessings,

Bruce
Post Reply