Change Item's TextStyle

General TRichView support forum. Please post your questions here
Post Reply
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

Change Item's TextStyle

Post by mohsen24000 »

Hi,
How can i change item's textstyle without ApplyTextStyle!?
for example, I want to change textstyle of all items that textstyleno=1 to 0.
thanks a lot.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

procedure ChangeTextStyle(RVData: TCustomRVData; FromStyleNo, ToStyleNo: Integer);
var i,r,c: Integer; 
    table: TRVTableItemInfo; 
begin 
  for i := 0 to RVData.ItemCount-1 do 
    if RVData.GetItemStyle(i)=FromStyleNo then begin 
      [color=blue]RVData.GetItem(i).StyleNo := ToStyleNo[/color]
    else if RVData.GetItemStyle(i)=rvsTable then begin 
      table := TRVTableItemInfo(RVData.GetItem(i)); 
      for r := 0 to table.Rows.Count-1 do 
        for c := 0 to table.Rows[r].Count-1 do 
          if table.Cells[r,c]<>nil then 
            ChangeTextStyle(table.Cells[r,c].GetRVData, FromStyleNo, ToStyleNo); 
    end; 
end;
Call:

Code: Select all

ChangeTextStyle(RichViewEdit1.RVData, 1, 0);
RichViewEdit1.ClearUndo; // this method cannot be undone
RichViewEdit1.Format;
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

Post by mohsen24000 »

Thank you again :)
Post Reply